var App = new App();

//头部和左侧控制器
app.controller('total', function ($scope, MyFactory, $timeout) {
    //菜单权限控制
    $scope.userid = localStorage.getItem('userid');
    $scope.nav = {};
    MyFactory.PostAjax('users/getUserMenus', {
        'userId': $scope.userid
    }, function (data) {
        if (data.length == 0) {
            App.alert("您暂时没有权限，需要最高管理员授权")
        }

        for (var i = 0; i < data.length; i++) {
            $scope.nav['i' + data[i].menuId] = true;
        }

        //如果有选中的状态，显示选中的那个
        if (localStorage.getItem('isSelect')) {
            var i = parseInt(localStorage.getItem('isSelect'));
            //如果这个之前选中的状态有权限，那么还给他显示
            if ($scope.nav['i' + i]) {
                for (var j = 1; j < 6; j++) {
                    $scope['isSelect' + j] = false;
                }
                $scope['isSelect' + i] = true;
                //否则显示有权限的那个模块
            } else {
                for (var i = 1; i < 6; i++) {
                    if ($scope.nav['i' + i]) {
                        for (var j = 1; j < 6; j++) {
                            $scope['isSelect' + j] = false;
                        }
                        $scope['isSelect' + i] = true;
                        break
                    }
                }
            }
            //如果没有选中就显示有权限的第一个模块
        } else {
            for (var i = 1; i < 6; i++) {
                if ($scope.nav['i' + i]) {
                    for (var j = 1; j < 6; j++) {
                        $scope['isSelect' + j] = false;
                    }
                    $scope['isSelect' + i] = true;
                    break
                }
            }
        }

        //存取权限数据
        var powerData = angular.copy(data);
        var module1 = [],
            module2 = [],
            module3 = [],
            module4 = [],
            module5 = [];
        $.each(powerData, function (index, menu) {
            var module = menu.menuId.substring(0, 1);
            if (module == 1 && menu.menuUrl != '') {
                module1.push(menu);
            } else if (module == 2 && menu.menuUrl != '') {
                module2.push(menu);
            } else if (module == 3 && menu.menuUrl != '') {
                module3.push(menu);
            } else if (module == 4 && menu.menuUrl != '') {
                module4.push(menu);
            } else if (module == 5 && menu.menuUrl != '') {
                module5.push(menu);
            }
        });
        var moduleobj = {
            'module1': module1,
            'module2': module2,
            'module3': module3,
            'module4': module4,
            'module5': module5
        }

        sessionStorage.setItem('powerData', JSON.stringify(powerData));
        sessionStorage.setItem('moduleObj', JSON.stringify(moduleobj));


        //显示有权限的第一个页面
        var navArr = data;
        var navArr1 = [];
        for (var i = 0; i < navArr.length; i++) {
            navArr1.push(navArr[i].menuId);
        }
        navArr1.sort();
        $scope.navArr = navArr1;

        if (!localStorage.getItem('url')) {
            outer: for (var i = 0; i < navArr1.length; i++) {
                for (var j = 0; j < navArr.length; j++) {
                    if (navArr1[i] == navArr[j].menuId) {
                        if (navArr[j].menuUrl != '' && navArr[j].menuUrl.substr(10) != "#/") {
                            location.href = navArr[j].menuUrl.substr(10);
                            localStorage.setItem('mainUrl', navArr[j].menuUrl.substr(10));
                            break outer;
                        }
                    }
                }
            }
        }


        //判断当前页是否有权限
        if (localStorage.getItem('url')) {
            var nowUrl = localStorage.getItem('url');
            var urlIndex = nowUrl.indexOf('#');
            var boolUrl = nowUrl.substr(urlIndex);
            var isPower = false;
            for (var i = 0; i < navArr.length; i++) {
                if (navArr[i].menuUrl.indexOf(boolUrl) > 0) {
                    isPower = true;
                    break
                }
            }
            //更新主页权限
            outer:
            for (var i = 0; i < navArr1.length; i++) {
                for (var j = 0; j < navArr.length; j++) {
                    if (navArr1[i] == navArr[j].menuId) {
                        if (navArr[j].menuUrl != '' && navArr[j].menuUrl.substr(10) != "#/") {
                            //location.href=navArr[j].menuUrl.substr(10);
                            localStorage.setItem('mainUrl', navArr[j].menuUrl.substr(10));
                            break outer;
                        }
                    }
                }
            }

            if (!isPower) {
                var href = localStorage.getItem('mainUrl');
                location.href = href;
            }

        }


    }) //权限ajax结束

    //选择菜单
    $scope.selectNav = function (index) {
        for (var i = 1; i < 6; i++) {
            $scope['isSelect' + i] = false;
        }
        $scope['isSelect' + index] = true;
        localStorage.setItem('isSelect', index + '');

        var module = JSON.parse(sessionStorage.getItem('moduleObj'));
        var moduleData;
        if (index == 1) {
            moduleData = module['module1'];
            var url = [];
            $.each(moduleData, function (index, menu) {
                url.push(menu.menuUrl);
            });

            if (url.indexOf('index.html#/appRunManage') != -1) {
                //                   $scope.nav['i'+index+'1']=true;

                location.href = '#/appRunManage';
                return;
            } else if (url.indexOf('index.html#/paramConfigManage') != -1) {
                //          			$scope.nav['i12']=true;
                App.d(".ul12").style.display = 'block';
                App.d(".ul121").style.display = 'block';
                location.href = '#/paramConfigManage';

                return;
            } else if (url.indexOf('index.html#/smsTypeManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul121").style.display = 'block';
                location.href = '#/smsTypeManage';
                return;
            } else if (url.indexOf('index.html#/channelParameter') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul121").style.display = 'block';
                location.href = '#/channelParameter';
                return;
            } else if (url.indexOf('index.html#/smsBsManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul121").style.display = 'block';
                location.href = '#/smsBsManage';
                return;
            } else if (url.indexOf('index.html#/errorCodemManagement') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul121").style.display = 'block';
                location.href = '#/errorCodemManagement';
                return;
            } else if (url.indexOf('index.html#/forbiddentimeManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/forbiddentimeManage';
                return;
            } else if (url.indexOf('index.html#/repeatFilterManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/repeatFilterManage';
                return;
            } else if (url.indexOf('index.html#/sensitiveWordManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/sensitiveWordManage';
                return;
            } else if (url.indexOf('index.html#/blackListimport') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/blackListimport';
                return;
            } else if (url.indexOf('index.html#/redListimport') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/redListimport';
                return;
            } else if (url.indexOf('index.html#/invalidUserimport') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/invalidUserimport';
                return;
            } else if (url.indexOf('index.html#/conditionSmsManage') != -1) {
                location.href = '#/conditionSmsManage';
                return;
            } else if (url.indexOf('index.html#/businessRouteManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/businessRouteManage';
                return;
            } else if (url.indexOf('index.html#/segmentroutManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/segmentroutManage';
                return;
            } else if (url.indexOf('index.html#/priorityManage') != -1) {
                App.d(".ul12").style.display = 'block';
                App.d(".ul1221").style.display = 'block';
                location.href = '#/priorityManage';
                return;
            } else if (url.indexOf('index.html#/internetSwitch') != -1) {
                location.href = '#/internetSwitch';
                return;
            } else {
                //这个代表这个模块的页面都没有权限
            }
        } else if (index == 2) {
            moduleData = module['module2'];
            var url = [];
            $.each(moduleData, function (index, menu) {
                url.push(menu.menuUrl);
            });
            if (url.indexOf('index.html#/unifyMonitor') != -1) {
                //                    $scope.nav['i'+index+'1']=true;
                //                    App.d(".l"+index).style.display='block';
                location.href = '#/smunifyMonitor';
                return;
            } else if (url.indexOf('index.html#/hostMonitor') != -1) {
                App.d(".ul221").style.display = 'block';
                App.d(".ul2211").style.display = 'block';
                location.href = '#/hostMonitor';
                return;
            } else if (url.indexOf('index.html#/systemMonitor') != -1) {
                App.d(".ul221").style.display = 'block';
                App.d(".ul2211").style.display = 'block';
                location.href = '#/systemMonitor';
                return;
            } else if (url.indexOf('index.html#/redisMonitor') != -1) {
                App.d(".ul221").style.display = 'block';
                location.href = '#/redisMonitor';
                return;
            } else if (url.indexOf('index.html#/tomcatMonitor') != -1) {
                App.d(".ul221").style.display = 'block';
                location.href = '#/tomcatMonitor';
                return;
            } else if (url.indexOf('index.html#/indexMonitor') != -1) {
                App.d(".ul23").style.display = 'block';
                location.href = '#/indexMonitor';
                return;
            } else if (url.indexOf('index.html#/joinMonitor') != -1) {
                App.d(".ul23").style.display = 'block';
                location.href = '#/joinMonitor';
                return;
            } else if (url.indexOf('index.html#/businessMonitor') != -1) {
                App.d(".ul23").style.display = 'block';
                location.href = '#/businessMonitor';
                return;
            } else if (url.indexOf('index.html#/smsMonitor') != -1) {
                App.d(".ul23").style.display = 'block';
                location.href = '#/smsMonitor';
                return;
            } else if (url.indexOf('index.html#/priorityMonitor') != -1) {
                App.d(".ul23").style.display = 'block';
                location.href = '#/priorityMonitor';
                return;
            } else if (url.indexOf('index.html#/objManage') != -1) {
                location.href = '#/objManage';
                return;
            } else if (url.indexOf('index.html#/warnCollectMonitor') != -1) {
                location.href = '#/warnCollectMonitor';
                return;
            } else if (url.indexOf('index.html#/warnDetailMonitor') != -1) {
                App.d(".ul23").style.display = 'block';
                location.href = '#/warnDetailMonitor';
                return;
            } else if (url.indexOf('index.html#/unifyMonitor') != -1) {
                App.d(".ul23").style.display = 'block';
                location.href = '#/unifyMonitor';
                return;
            } else {

                //这个代表这个模块的页面都没有权限
            }

        } else if (index == 3) {
            moduleData = module['module3'];
            var url = [];
            $.each(moduleData, function (index, menu) {
                url.push(menu.menuUrl);
            });
            if (url.indexOf('index.html#/sendStat') != -1) {
                App.d(".ul31").style.display = 'block';
                location.href = '#/sendStat';
                return;
            } else if (url.indexOf('index.html#/sendDetail') != -1) {
                App.d(".ul31").style.display = 'block';
                location.href = '#/sendDetail';
                return;
            } else if (url.indexOf('index.html#/recieveDetail') != -1) {
                App.d(".ul31").style.display = 'block';
                location.href = '#/recieveDetail';
                return;
            } else if (url.indexOf('index.html#/oprateRecord') != -1) {
                App.d(".ul32").style.display = 'block';
                location.href = '#/oprateRecord';
                return;
            } else if (url.indexOf('index.html#/opratedetails') != -1) {
                App.d(".ul32").style.display = 'block';
                location.href = '#/opratedetails';
                return;
            } else if (url.indexOf('index.html#/sendOprate') != -1) {
                App.d(".ul32").style.display = 'block';
                location.href = '#/sendOprate';
                return;
            } else {
                //这个代表这个模块的页面都没有权限
            }

        } else if (index == 4) {
            moduleData = module['module4'];
            var url = [];
            $.each(moduleData, function (index, menu) {
                url.push(menu.menuUrl);
            });
            if (url.indexOf('index.html#/smsStatistics') != -1) {
                //               $scope.nav['i'+index+'1']=true;
                App.d(".ul41").style.display = 'block';
                location.href = '#/smsStatistics';
                return;
            } else if (url.indexOf('index.html#/smsDetails') != -1) {
                App.d(".ul41").style.display = 'block';
                location.href = '#/smsDetails';
                return;
            } else if (url.indexOf('index.html#/userStatistics') != -1) {
                App.d(".ul42").style.display = 'block';
                location.href = '#/userStatistics';
                return;
            } else if (url.indexOf('index.html#/userDetails') != -1) {
                App.d(".ul42").style.display = 'block';
                location.href = '#/userDetails';
                return;
            } else if (url.indexOf('index.html#/numActivationDetails') != -1) {
                App.d(".ul42").style.display = 'block';
                location.href = '#/numActivationDetails';
                return;
            } else if (url.indexOf('index.html#/dsTrafficStatistics') != -1) {
                App.d(".ul43").style.display = 'block';
                location.href = '#/dsTrafficStatistics';
                return;
            } else if (url.indexOf('index.html#/dsSmsDetails') != -1) {
                App.d(".ul43").style.display = 'block';
                location.href = '#/dsSmsDetails';
                return;
            } else if (url.indexOf('index.html#/upTrafficStatistics') != -1) {
                App.d(".ul43").style.display = 'block';
                location.href = '#/upTrafficStatistics';
                return;
            } else if (url.indexOf('index.html#/upSmsStatistics') != -1) {
                App.d(".ul43").style.display = 'block';
                location.href = '#/upSmsStatistics';
                return;
            } else if (url.indexOf('index.html#/settlementStatementM') != -1) {
                location.href = '#/settlementStatementM';
                return;
            } else {
                //这个代表这个模块的页面都没有权限
            }
        } else {
            moduleData = module['module5'];
            var url = [];
            $.each(moduleData, function (index, menu) {
                url.push(menu.menuUrl);
            });

            if (url.indexOf('index.html#/userManagement') != -1) {
                //                  $scope.nav['i'+index+'1']=true;
                //                  App.d(".l"+index).style.display='block';
                location.href = '#/userManagement';
                return;
            } else if (url.indexOf('index.html#/roleManagement') != -1) {
                location.href = '#/roleManagement';
                return;
            } else if (url.indexOf('index.html#/organizationManagement') != -1) {
                location.href = '#/organizationManagement';
                return;
            } else if (url.indexOf('index.html#/logManagement') != -1) {
                location.href = '#/logManagement';
                return;
            } else {
                //这个代表这个模块的页面都没有权限
            }
        }
    }
    //展开左侧对应项

    //存取历史链接
    $timeout(function () {
        //路由跳转成功调用
        $scope.$on("$routeChangeSuccess", function (event, next, current) {
            localStorage.setItem('url', location.href);
            //给菜单显示高亮
            var nowUrl = location.href;
            var urlIndex = nowUrl.indexOf('#');
            var boolUrl = nowUrl.substr(urlIndex);
            //模块切换
            if (sessionStorage.getItem('powerData')) {
                var data = JSON.parse(sessionStorage.getItem('powerData'));

                for (var i = 0; i < data.length; i++) {
                    if (data[i].menuUrl.indexOf(boolUrl) != -1) {
                        var num = data[i].menuId.substr(0, 1);
                        for (var i = 1; i < 6; i++) {
                            $scope['isSelect' + i] = false;
                        }
                        $scope['isSelect' + num] = true;
                        localStorage.setItem('isSelect', num + '');
                        break
                    }
                }
            }

            //排除tab页,如果是tab也切换高亮
            if (boolUrl.indexOf('invalidUserManage') != -1 ||
                boolUrl.indexOf('errorCodeImport') != -1 ||
                boolUrl.indexOf('errorCodeImportDetail') != -1 ||
                boolUrl.indexOf('blackListManage') != -1 ||
                boolUrl.indexOf('redListManage') != -1 ||
                boolUrl.indexOf('messagepriorityMent') != -1 ||
                boolUrl.indexOf('childObjManage') != -1 ||
                boolUrl.indexOf('attributeManage') != -1 ||
                boolUrl.indexOf('setupManage') != -1 ||
                boolUrl.indexOf('warnPersonManage') != -1 ||
                boolUrl.indexOf('settlementStatementY') != -1 ||
                boolUrl.indexOf('childObjManage') != -1 ||
                boolUrl.indexOf('reserveStat') != -1
            ) {
                return
            }

            //菜单高亮
            var oA = App.d('.site-menu a');
            for (var i = 0; i < oA.length; i++) {
                for (var j = 0; j < oA.length; j++) {
                    oA[j].style.color = 'rgba(163, 175, 183, 0.9)';
                }
                if (oA[i].href.indexOf(boolUrl) != -1) {
                    oA[i].style.color = '#fff';
                    break
                }
            }



        });
    }, 20)

    //主页跳转
    $scope.mainGo = function () {
        if (localStorage.getItem('mainUrl')) {
            location.href = localStorage.getItem('mainUrl');
        } else {
            App.alert('你没有主页权限');
        }

    }


    //登入后验证账号安全性
    MyFactory.PostAjax('login/validPwd', {
        'userId': $scope.userid
    }, function (data) {

        if (data.code != '0' && !data.isSuccess) {
            App.alert(data.msg, function () {
                $scope.$apply($scope.showMe = true)
            })
        }

    })

    //显示用户名
    $scope.userName = localStorage.getItem('username');

    //定义密码模型
    $scope.oldPassword = '';
    $scope.newPassword = '';
    $scope.confirmPassword = '';
    $scope.editPasswordError = '';
    //修改密码
    $scope.editPassword = function () {
        if ($scope.oldPassword == '') {
            return $scope.editPasswordError = '请输入原密码';
        } else if ($scope.newPassword == '') {
            return $scope.editPasswordError = '请输入新密码';
        } else if ($scope.confirmPassword == '') {
            return $scope.editPasswordError = '请确认密码'
        } else if ($scope.newPassword != $scope.confirmPassword) {
            return $scope.editPasswordError = '密码不一致，请重新输入';
        }

        // 检验密码规则是否正确
        // 8到16位，且包含大写字母、小写字母、数字和特殊符号任意三种以上组合
        var passRegx = /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{8,16}$/;

        if (!passRegx.test($scope.newPassword)) {
            return App.alert("请设置8到16位，且包含大写字母、小写字母、数字和特殊符号任意三种以上组合的有效密码!");
        }
        MyFactory.PostAjax('/login/changePwd', {
            'oldPassword': hex_md5($scope.oldPassword),
            'newPassword': hex_md5($scope.newPassword),
            'userId': $scope.userid
        }, function (data) {
            if (!data.isSuccess) {
                return App.alert(data.msg)
            }
            // 请求成功
            $scope.oldPassword = '';
            $scope.newPassword = '';
            $scope.confirmPassword = '';
            App.alert(data.msg, function () {
                $scope.$apply($scope.showMe = false);
            })
        })
    };

    //退出登入
    $scope.exit = function () {

        MyFactory.PostAjax('/login/logout', {
            'userId': $scope.userid
        }, function (data) {
            if (data.isSuccess) {
                localStorage.removeItem('userid');
                localStorage.removeItem('username');
                localStorage.removeItem('isSelect');
                localStorage.removeItem('url');
                location.href = 'login.html'
            }
        })

    }

})





//===========程序运行管理============//
app.controller('appRunManage', function ($scope, MyFactory, $timeout) {
    // 权限判断
    MyFactory.GetAjaxs('users/authentication', 'appRunManage', function (data) {
        if (data.data.isSuccess) {

            //搜索数据模型
            $scope.searchData = {
                deployId: '',
                prgName: '',
            }


            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };



            //初始化数据

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/program/query', $scope.searchData, function (data) {
                    $scope.all = false;
                    $scope.result = data.result;
                    for (var i = 0; i < $scope.result.length; i++) {
                        $scope.result[i].checked = false;
                        $scope.all = false;
                    }
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    if (callback) {
                        callback();
                    }
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/program/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                        $scope.all = false;
                    })
                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //多项操作
            //全部选中操作
            $scope.select_all = function () {
                if ($scope.all) {
                    for (var i = 0; i < $scope.result.length; i++) {
                        $scope.result[i].checked = true
                    }
                } else {
                    for (var i = 0; i < $scope.result.length; i++) {
                        $scope.result[i].checked = false;
                    }
                }
            }
            //请求操作
            $scope.changeStatus = function (status) {
                var arr = [];
                var arrNum = 0;
                for (var i = 0; i < $scope.result.length; i++) {
                    if ($scope.result[i].checked) {
                        arr.push({
                            'id': $scope.result[i].prgId,
                            'send': false
                        })
                    }
                }

                var url = '/program/changeStatus';
                var str = ''
                switch (status) {
                    case '1':
                        str = '启动';
                        break
                    case '4':
                        str = '停止';
                        break
                    case '2':
                        str = '重载';
                        break
                }

                if (arr.length === 0) {
                    App.alert('请选择需要' + str + '的选项');
                    return
                }

                $scope.loadStatus = str;
                $scope.statusLoad = {
                    'display': 'block'
                };
                //开始请求后台进行操作
                for (var i = 0; i < arr.length; i++) {
                    (function (i) {
                        MyFactory.PostAjax(url, {
                            'prgId': arr[i].id,
                            'notifyType': status
                        }, function (data) {
                            arrNum++;
                            if (data.isSuccess == true) {
                                arr[i].send = true;
                            };
                            completeSend();
                        })
                    })(i)
                }

                //回调函数
                function completeSend() {
                    var sendStatus = true;
                    if (arrNum == arr.length) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        for (var i = 0; i < arr.length; i++) {
                            if (arr[i].send == false) {
                                var sendStatus = false
                            }
                        }
                        if (sendStatus) {
                            App.alert(str + '成功')
                        } else {
                            App.alert(str + '失败')
                        }
                    }

                }
            }



            //暂停,启动，停止
            $scope.statusLoad = {
                'display': 'none'
            };
            $scope.startUp = function (id, $event, index) {
                $scope.loadStatus = '启动';
                $scope.statusLoad = {
                    'display': 'block'
                };
                var ele = $event.target;
                var data = {
                    'prgId': id,
                    'notifyType': '1'
                }
                MyFactory.runningStatus(data, ele, index, $scope, 1);
            }
            $scope.stopUp = function (id, $event, index) {
                $scope.loadStatus = '停止';
                $scope.statusLoad = {
                    'display': 'block'
                };
                var ele = $event.target;
                var data = {
                    'prgId': id,
                    'notifyType': '4'
                }
                MyFactory.runningStatus(data, ele, index, $scope, 4)
            }
            $scope.restart = function (id, $event, index) {
                $scope.loadStatus = '重载';
                $scope.statusLoad = {
                    'display': 'block'
                };
                var ele = $event.target;
                var data = {
                    'prgId': id,
                    'notifyType': '2'
                }
                MyFactory.runningStatus(data, ele, index, $scope, 2);
                // if (status == '4') {
                //     App.alert('停止状态不能重载');
                //     return
                // }
                // $scope.loadStatus = '重载';
                // $scope.statusLoad = {
                //     'display': 'block'
                // };
                // MyFactory.PostAjax('program/changeStatus', data, function (data) {
                //     if (data.isSuccess == true) {
                //         $scope.statusLoad = {
                //             'display': 'none'
                //         };
                //         $scope.upData();
                //         App.alert(data.msg)
                //     } else {
                //         $scope.statusLoad = {
                //             'display': 'none'
                //         };
                //         App.alert(data.msg)
                //     }
                // })
            }

            MyFactory.runningStatus = function(data, ele, index, $scope, status) {
                MyFactory.PostAjax('program/changeStatus', data, function (data) {
                    if (data.isSuccess == true) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        $scope.upData();
                        App.alert(data.msg)
                    } else {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        App.alert(data.msg)
                    }
                })
            }


            //====删除tr====//
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/program/delete', {
                    'prgId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })

            };
            //====添加tr和编辑tr====//
            $scope.addData = {
                prgId: '',
                isSave: true,
                prgName: '',
                deployDir: '',
                deployId: '',
                groupName: '',
                desc: '',
                prgExtInfos: [],
                moduleName: ''
            }
            $scope.editTr = function (value, id) {
                App.debugPrompt();
                $scope.popup = value;
                if (value == '添加') {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        prgId: '',
                        isSave: true,
                        prgName: '',
                        deployDir: '',
                        deployId: '',
                        groupName: '',
                        desc: '',
                        prgExtInfos: [ ],
                        moduleName: ''
                    }

                } else {
                    $scope.isDisabled = true;
                    $scope.editId = id;
                    MyFactory.PostAjax('/program/toUpdate', {
                        'prgId': id
                    }, function (data) {
                        $scope.addData = {};
                        $scope.addData.prgId = data.prgId;
                        $scope.addData.prgName = data.prgName;
                        $scope.addData.deployId = data.deployId;
                        $scope.addData.deployDir = data.deployDir;
                        $scope.addData.groupName = data.groupName;
                        $scope.addData.desc = data.desc;
                        $scope.addData.prgExtInfos = data.prgExtInfos;
                        $scope.addData.moduleName = data.moduleName;
                    })
                }
            };
            $scope.editSave = function () {
                if ($scope.popup == '修改') {
                    $scope.loadStatus = '修改';
                    $scope.addOrUpdate();
                    // MyFactory.runAddOrEdit($scope);
                    $scope.upData();
                } else if ($scope.popup == '添加') {
                    // MyFactory.runAddOrEdit($scope);
                    $scope.addOrUpdate();
                    $scope.upData();
                }

            }
            $scope.addOrUpdate = function () {
                MyFactory.PostAjax('program/saveOrUpdate', {
                    isSave: $scope.popup == '添加',
                    prgId: $scope.addData.prgId,
                    prgName: $scope.addData.prgName,
                    deployId: $scope.addData.deployId,
                    deployDir: $scope.addData.deployDir,
                    groupName: $scope.addData.groupName,
                    desc: $scope.addData.desc,
                    prgExtInfos: JSON.stringify($scope.addData.prgExtInfos),
                    moduleName: $scope.addData.moduleName
                }, function (data) {
                    if(data.isSuccess) {
                        App.alert(data.msg, function () {
                            $('#add1').modal('hide');
                        });
                    } else {
                        App.alert(data.msg);
                    }
                })
            }
            //=====添加参数=====//
            $scope.addConfig = function () {
                $scope.addData.prgExtInfos.push({
                    'recId': '',
                    'paramName': '',
                    'paramNameCn': '',
                    'paramValue': ''
                });

            }
            //=====删除参数======//
            $scope.deleteConfig = function (index) {
                $scope.addData.prgExtInfos.splice(index, 1);
            }

            $scope.checkEditIp = function () {
                if (!App.regEx(App.d('#editIp').value, 'ip')) {
                    App.promptOne(App.d('#editIp'), 'ip格式不正确')
                }
            }

        } else {

            location.href = '#/forbid';
        }
    })


});
//====paramConfigManage 业务端管理====//by@wjf
app.controller('paramConfigManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'paramConfigManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                svrNode: '',
                svrNodeName: '',
                upflag: '',
                srvtype: ''
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/svrNodeDef/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.count = data.totalCount;
                    $scope.selPage = data.pageNo
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    if (callback) {
                        callback()
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/svrNodeDef/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            };
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);
            //短信设置
            MyFactory.PostAjax('/serviceCodeDef/getAll', '', function (data) {
                $scope.setData = [];
                for (var i = 0; i < data.length; i++) {
                    $scope.setData.push({
                        'serviceName': data[i].serviceName,
                        'serviceCode': data[i].serviceCode,
                        'isSelected': false
                    })
                };
                $scope.dataCache = $scope.setData;
            });

            $scope.smsSel = [];
            $scope.checkboxClick = function ($event, idx) {
                var checkbox = $event.target;
                if (checkbox.checked) {
                    $scope.setData.splice(idx, 1);
                    $scope.smsSel.push({
                        'serviceName': checkbox.getAttribute('sName'),
                        'serviceCode': checkbox.getAttribute('value'),
                        'isSelected': true
                    });
                } else {
                    $scope.smsSel.splice(idx, 1);
                    $scope.setData.push({
                        'serviceName': checkbox.getAttribute('sName'),
                        'serviceCode': checkbox.getAttribute('value'),
                        'isSelected': false
                    });
                }

            };

            //点击设置
            $scope.smsSettings = function (svrNode) {
                $scope.svrNode = svrNode;
                var obj = document.getElementsByName('smsSettingsItem');
                for (var j = 0; j < obj.length; j++) { //默认为不勾选
                    $(obj[j]).prop("checked", false);
                }
                MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                    'svrNode': svrNode
                }, function (data) {
                    if (data.length > 0) {
                        $scope.smsSel = [];
                        for (var i = 0; i < data.length; i++) {
                            $scope.smsSel.push({
                                'serviceName': data[i].serviceName,
                                'serviceCode': data[i].serviceCode,
                                'isSelected': true
                            })
                        }
                        for (var index = 0; index < $scope.smsSel.length; index++) {
                            for (var l = 0; l < $scope.setData.length; l++) {
                                if ($scope.setData[l].serviceCode == $scope.smsSel[index].serviceCode) {
                                    $scope.setData.splice(l, 1);
                                }
                            }
                        }
                    }

                });
                //短息设置的保存
                $scope.setSave = function (value) {
                    var list = $(".checkboxSelList input");
                    var arr = [];
                    for (var i = 0; i < list.length; i++) {
                        if ($(list[i]).prop('checked') == true) {
                            arr.push($(list[i]).val());
                        }
                    };
                    var str = arr.join(',');
                    MyFactory.PostAjax('/svrNodeDef/updateServiceCode', {
                        'svrNode': $scope.svrNode,
                        'serviceCodes': str
                    }, function (data) {
                        if (data.isSuccess == true) {
                            App.alert(data.msg, function () {
                                $('#smsSettings').modal('hide');
                            });
                        } else {
                            App.alert(data.msg);
                        }
                    });
                }
                //短息设置的取消
                $scope.cancel = function () {
                    $scope.smsSel = [];
                    MyFactory.PostAjax('/serviceCodeDef/getAll', '', function (data) {
                        $scope.setData = [];
                        for (var i = 0; i < data.length; i++) {
                            $scope.setData.push({
                                'serviceName': data[i].serviceName,
                                'serviceCode': data[i].serviceCode,
                                'isSelected': false
                            })
                        };
                    });
                }
            }


            //点击生效与无效
            $scope.changee = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('svrNodeDef/changeStatus', {
                    'svrNode': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '生效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
            //删除记录
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/svrNodeDef/delete', {
                    'svrNode': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        $scope.result.splice($scope.deleteIndex, 1);
                        App.alert(data.msg)
                    }
                })

            };

            //添加或者编辑挂载数据
            $scope.addData = {
                maxFlux: '',
                acceptMo: '',
                acceptReport: '',
                smTypecheck: '',
                svrNode: '',
                svrNodeName: '',
                upflag: '1',
                conNum: '',
                loginUser: '',
                loginPwd: '',
                serverIp: '',
                serverPort: '',
                loginSvrUser: '',
                loginSvrPwd: '',
                sendPort: '',
                status: '1',
                desc: '',
                srvtype: ''
            }
            $scope.editTr = function (str, svrNode) {
                $scope.popup = str;
                $scope.isDisabled = true;
                if (str == '修改') {
                    MyFactory.PostAjax('svrNodeDef/toUpdate', {
                        'svrNode': svrNode
                    }, function (data) {
                        $scope.addData = {
                            maxFlux: data.maxFlux,
                            acceptMo: data.acceptMo,
                            acceptReport: data.acceptReport,
                            smTypecheck: data.smTypecheck,
                            svrNode: data.svrNode,
                            svrNodeName: data.svrNodeName,
                            upflag: data.upflag,
                            conNum: data.conNum,
                            loginUser: data.loginUser,
                            loginPwd: data.loginPwd,
                            serverIp: data.serverIp,
                            serverPort: data.serverPort,
                            loginSvrUser: data.loginSvrUser,
                            loginSvrPwd: data.loginSvrPwd,
                            sendPort: data.sendPort,
                            status: data.status,
                            desc: data.desc,
                            srvtype: data.srvtype
                        };
                        if ($scope.addData.srvtype == "是") {
                            $scope.addData.srvtype = "1"
                        } else if ($scope.addData.srvtype == "否") {
                            $scope.addData.srvtype = "0"
                        }
                    })
                } else {
                    $scope.addData = {
                        maxFlux: '',
                        acceptMo: '',
                        acceptReport: '',
                        smTypecheck: '',
                        svrNode: '',
                        svrNodeName: '',
                        upflag: '1',
                        conNum: '',
                        loginUser: '',
                        loginPwd: '',
                        serverIp: '',
                        serverPort: '',
                        loginSvrUser: '',
                        loginSvrPwd: '',
                        sendPort: '',
                        status: '1',
                        desc: '',
                        srvtype: ''
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input.show")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '业务端说明不能为空');
                    return
                }
                if (!App.regEx($scope.addData.serverIp, 'ip')) {
                    App.alert('服务ip格式不正确');
                    return
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    $("input[name='White']:checked").each(function () {
                        if (true == $(this).prop('checked')) {
                            $scope.addData.isWhite = $(this).prop('value');
                        }
                    })
                    MyFactory.PostAjax('svrNodeDef/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
                if ($scope.popup == '添加') {
                    MyFactory.PostAjax('svrNodeDef/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            });
                            $scope.upData();
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }
            // 白名单选择设置
            $scope.whiteData = {
                srvtype: '',
                svrNode: ''
            }
            $scope.editwhite = function (srvtype, svrNode) {
                if (srvtype == "是") {
                    $scope.whiteData = {
                        srvtype: "1",
                        svrNode: svrNode
                    }
                } else if (srvtype == "否") {
                    $scope.whiteData = {
                        srvtype: "0",
                        svrNode: svrNode
                    }
                }
            }

            // 白名单设置
            $scope.editList = function () {
                $("input[name='isWhite']:checked").each(function () {
                    if (true == $(this).prop('checked')) {
                        $scope.whiteData.srvtype = $(this).prop('value');
                    }
                })
                MyFactory.PostAjax('/svrNodeDef/changeIsWhite', $scope.whiteData, function (data) {
                    $scope.isSuccess = data.isSuccess;
                    $scope.code = data.code;
                    $scope.msg = data.msg;
                    if (data.success == true) {
                        App.alert(data.msg, function () {
                            $('#iswhite').modal('hide');
                        });
                        $scope.upData();
                    } else {
                        App.alert(data.msg);
                    }
                });
                $scope.upData();
            }

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
        } else {

            location.href = '#/forbid';
        }
    });


}); //end by controller


//=====smsTypeManage 短信类型管理=======//
app.controller('smsTypeManage', function ($scope, $timeout, $http, MyFactory) {

    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsTypeManage', function (data) {
        if (data.data.isSuccess) {
            //初始化
            $scope.searchData = {
                'serviceCode': '',
                'serviceName': ''
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/serviceCodeDef/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    if (callback) {
                        callback()
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/serviceCodeDef/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('serviceCodeDef/changeStatus', {
                    'serviceCode': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'serviceCode': '',
                'serviceName': '',
                'SVR_NODE': '',
                'status': '',
                'acceptMo': '',
                'desc': '',

            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('serviceCodeDef/toUpdate', {
                        'serviceCode': code
                    }, function (data) {
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.serviceName = data.serviceName;
                        $scope.addData.acceptMo = data.acceptMo;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                    })
                } else {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'serviceCode': '',
                        'serviceName': '',
                        'SVR_NODE': '',
                        'status': '1',
                        'acceptMo': '',
                        'desc': '',
                    }
                }
            }

            //不能为特殊字符
            $scope.stripscript = function () {

                var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]")
                var rs = "";
                for (var i = 0; i < $scope.addData.serviceName.length; i++) {
                    rs = rs + $scope.addData.serviceName.substr(i, 1).replace(pattern, '');
                }
                $scope.addData.serviceName = rs;
            }

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '业务端说明不能为空');
                    return
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('serviceCodeDef/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('serviceCodeDef/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.code = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('serviceCodeDef/delete', {
                    'serviceCode': $scope.code
                }, function (data) {
                    if (data.isSuccess == true) {
                        App.alert(data.msg);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };

        } else {

            location.href = '#/forbid';
        }
    });
});

//========= 短信接入分级=========//
app.controller('smsAccessGrade', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsTypeManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                svrNode: '',
                serviceCode: '',
                type: '',
                startDate: '',
                endDate: ''
            };

            MyFactory.Date2($scope, '#smsAccessDate', 'startDate', 'endDate');

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/svrSpeed/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    if (callback) {
                        callback()
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'svrSpeed/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            })
            //短信类型下拉列表
            MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                $scope.listData2 = data;
            })

            // 短信级联
            $scope.getSms = function () {
                Myfactory.PostAjax('/svrNodeDef/getBySvrNode', {
                    "svrNode": $scope.searchData.svrNode
                }, function (data) {
                    $scope.listData2 = data;
                })
            }

            //时间调用
            $('#smsAccessDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsAccessDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            //查询
            $scope.search = function (e) {

                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#smsAccessDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $scope.upData();
                    }

                } else {
                    var strData = $("#smsAccessDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $scope.upData();
                }


            }

            $scope.Speed = [{
                'index': 1,
                'Name': '条/秒'
            }, {
                'index': 2,
                'Name': '条/分'
            }, {
                'index': 3,
                'Name': '条/时'
            }];
            $scope.Flow = [{
                'index': 4,
                'Name': '条/日'
            }, {
                'index': 5,
                'Name': '条/月'
            }]

            $scope.seleMonitor = function (code) {
                if (code == 1) {
                    $scope.selectData = $scope.Speed;
                } else if (code == 2) {
                    $scope.selectData = $scope.Flow;
                }
            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'svrNode': '',
                'serviceCode': '',
                'limittype': '',
                'flowspeed': '',
                'timeunit': '',
                'recId': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/svrSpeed/toUpdate', {
                        'recId': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode);
                        $scope.addData.recId = data.recId;
                        $scope.addData.svrNode = data.svrNode;
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.limittype = data.limittype;
                        $scope.addData.flowspeed = data.flowspeed;
                        $scope.addData.timeunit = data.timeunit;
                        if (data.limittype == '1') {
                            $scope.selectData = $scope.Speed;
                        } else if (data.limittype == '2') {
                            $scope.selectData = $scope.Flow;
                        }
                    })
                } else {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'svrNode': '',
                        'serviceCode': '',
                        'limittype': '',
                        'flowspeed': '',
                        'timeunit': ''
                    }
                }
            }
            //不能为特殊字符
            $scope.stripscript = function () {

                var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]")
                var rs = "";
                for (var i = 0; i < $scope.addData.serviceName.length; i++) {
                    rs = rs + $scope.addData.serviceName.substr(i, 1).replace(pattern, '');
                }
                $scope.addData.serviceName = rs;
            }

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input");
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                        break;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('/svrSpeed/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('/svrSpeed/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.code = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/svrSpeed/delete', {
                    'recId': $scope.code
                }, function (data) {
                    if (data.isSuccess == true) {
                        App.alert(data.msg);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            $scope.load = function (value) {
            }
        } else {

            location.href = '#/forbid';
        }
    });

});
//========通道参数管理==========//
app.controller('channelParameter', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'channelParameter', function (data) {
        if (data.data.isSuccess) {
            //初始化
            $scope.searchData = {
                gateLinkId: '',
                status: ''
            };
            //路由设置弹窗数据
            MyFactory.PostAjax('serviceCodeDef/getAll', '', function (data) {
                $scope.listTypeData = data;
            });

            //短信通道列表请求
            $scope.downData = function () {
                MyFactory.PostAjax('gateDef/getGateLink', {
                    "status": "-1"
                }, function (data) {
                    $scope.showData = data;
                });
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/gateDef/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        if (callback) {
                            callback()
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/gateDef/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.downData();
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //短信发送规则
            $scope.init = function () {
                //初始化运营商
                MyFactory.PostAjax('/dicDef/getByDicName', {
                    'dicName': 'mobileCorp'
                }, function (data) {
                    $scope.mobileCorpData = data;
                    for (var i = 0; i < data.length; i++) {
                        $("#mobileCorp").append("<label><input type='checkbox' value='" + data[i].DICVALUE + "'name='mobileCorp'/></label>" + data[i].DICVALUENAME);
                    };
                });
                //初始化省份
                MyFactory.PostAjax('/province/getAll', {}, function (data) {
                    $scope.setData2 = [];
                    var strHtml2 = '';
                    onclick = "setSelectAll();"
                    for (var i = 0; i < data.length; i++) {
                        //$("#province").append("<input type='checkbox' value='"+data[i].proCode+"' name='province'/>"+data[i].proName);
                        $("#provinceAll").append("<label><input type='checkbox'  value='" + data[i].proCode + "' name='province'/></label>" + data[i].proName);
                    };
                });

                //点击发送规则
                $scope.sendingRule = function (gateLinkId) {
                    $scope.gateLinkId = gateLinkId;
                    var initOption = document.getElementsByName('setOption');
                    for (var h = 0; h < initOption.length; h++) { //默认为不勾选
                        $(initOption[h]).prop("checked", false);
                    }
                    //获取可发送运营商
                    $('#checkAll').prop("checked", false);
                    var checked = false;
                    var obj = document.getElementsByName('mobileCorp');
                    for (var j = 0; j < obj.length; j++) { //默认为不勾选
                        $(obj[j]).prop("checked", false);
                    }
                    MyFactory.PostAjax('/linkSendCorp/getByGateLinkId', {
                        'gateLinkId': gateLinkId
                    }, function (data) {
                        if (data.length > 0) {
                            for (var i = 0; i < data.length; i++) {
                                for (var j = 0; j < obj.length; j++) {
                                    if (obj[j].value == data[i].mobilCorp) {
                                        $(obj[j]).prop("checked", true);
                                    }
                                }
                            }
                        }
                    });
                    //获取可发送省份
                    var obj1 = document.getElementsByName('province');
                    for (var j = 0; j < obj1.length; j++) { //默认设置为不选
                        $(obj1[j]).prop("checked", false);
                    }
                    MyFactory.PostAjax('/linkSendPro/getByGateLinkId', {
                        'gateLinkId': gateLinkId
                    }, function (data) {
                        if (data.length > 0) {
                            for (var i = 0; i < data.length; i++) {
                                for (var j = 0; j < obj1.length; j++) {
                                    if (obj1[j].value == data[i].province) {
                                        $(obj1[j]).prop("checked", true);
                                    }
                                }
                            }
                        }
                    });
                }
                //点击全选
                $("#checkAll").click(function (event) {
                    if ($("#checkAll").prop("checked")) {
                        $("#provinceAll input").prop("checked", true);
                    } else {
                        $("#checkAll").prop("checked", false);
                    }
                });
                //点击本省
                $("#theProvince").click(function (event) {
                    if ($("#theProvince").prop("checked")) {
                        $("#provinceAll input").prop("checked", false);
                        $("#provinceAll input[type='checkbox'][value='44']").prop("checked", true);
                    }
                    $("#provinceAll input[type='checkbox'][value='44']").click(function (event) {
                        $("#theProvince").prop("checked", false);

                    });
                });
                //点击外省
                $("#otherProvinces").click(function (event) {

                    if ($("#otherProvinces").prop("checked")) {
                        $("#provinceAll input").prop("checked", true);
                        $("#provinceAll input[type='checkbox'][value='44']").prop("checked", false);
                    }
                });
                $('#provinceAll').on('click', "input[name='province']", function () {
                    //当没有选中某个子复选框时，SelectAll取消选中
                    if (!$("input[name='province']").checked) {
                        $("#checkAll").prop("checked", false);
                    }
                    var chsub = $("input[type='checkbox'][name='province']").length; //获取subcheck的个数
                    var checkedsub = $("input[type='checkbox'][name='province']:checked").length; //获取选中的subcheck的个数

                    if (checkedsub == chsub) {
                        $("#checkAll").prop("checked", true);
                    }

                });
                //短息设置的保存
                $scope.setSave = function () {
                    var str1 = '';
                    var str2 = '';
                    $("input[name='mobileCorp']:checkbox").each(function () {
                        if (true == $(this).prop("checked")) {
                            str1 += $(this).prop('value') + ',';
                        }
                    });
                    $("input[name='province']:checkbox").each(function () {
                        if (true == $(this).prop("checked")) {
                            str2 += $(this).prop('value') + ',';
                        }
                    });
                    MyFactory.PostAjax('/gateDef/changeLinkSend', {
                        'gateLinkId': $scope.gateLinkId,
                        'mobilCorps': str1,
                        'provinces': str2
                    }, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#sendRule').modal('hide');
                            })
                        } else {
                            App.alert(data.msg);
                        }
                    });
                }
                //路由设置点击
                $scope.routeLink = function (gateLinkId) {
                    $scope.routeLinkId = gateLinkId;
                    MyFactory.PostAjax('/routeGate/toUpdateByGate', {
                        'gateLinkId': gateLinkId
                    }, function (data) {
                        var ids = data.firstSvrIds ? data.firstSvrIds.split(",") : [ ];
                        angular.forEach($scope.listTypeData, function(type, index) {
                            $scope.listTypeData[index].checked = ids.indexOf(type.serviceCode) > -1;
                        });
                    });
                };

                //    路由设置弹窗的保存
                $scope.routeSave = function () {
                    var str3 = [];
                    $("input[name='listTypeItem']:checkbox").each(function () {
                        if (true == $(this).prop("checked")) {
                            str3.push($(this).prop('value'));
                        }
                    });
                    str3 = str3.toString();
                    MyFactory.PostAjax('/gateDef/updateRoute', {
                        'gateLinkId': $scope.routeLinkId,
                        'serviceCodes': str3
                    }, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#routerSettings').modal('hide');
                            })
                        } else {
                            App.alert(data.msg);
                        }
                    });
                }
            };
            $scope.init();
            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('gateDef/changeStatus', {
                    'gateLinkId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //添加或者编辑挂载数据(无短信速率字段)
            $scope.addData = {
                c: '',
                gateLinkName: '',
                spNumber: '',
                corpId: '',
                linkNum: '',

                status: '1',
                specialIp: '',
                specialPort: '',
                specialLoginUser: '',
                specialLoginPwd: '',
                internetIp: '',
                internetPort: '',
                internetLoginUser: '',
                internetLoginPwd: '',
                serverIp: '',
                serverPort: '',
                loginUser: '',
                loginPwd: '',
                mobileCorp: '1',
                desc: '',
                signType: '0',
                maxFlow: ''
            };
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('gateDef/toUpdate', {
                        'gateLinkId': code
                    }, function (data) {
                        $scope.addData.gateLinkId = data.gateLinkId;
                        $scope.addData.gateLinkName = data.gateLinkName;
                        $scope.addData.spNumber = data.spNumber;
                        $scope.addData.corpId = data.corpId;
                        $scope.addData.linkNum = data.linkNum;
                        $scope.addData.status = data.status;
                        $scope.addData.specialIp = data.specialIp;
                        $scope.addData.specialPort = data.specialPort;
                        // $scope.addData.desc=data.desc;sulv
                        $scope.addData.specialLoginUser = data.specialLoginUser;
                        $scope.addData.specialLoginPwd = data.specialLoginPwd;
                        $scope.addData.internetIp = data.internetIp;
                        $scope.addData.internetPort = data.internetPort;
                        $scope.addData.internetLoginUser = data.internetLoginUser;
                        $scope.addData.internetLoginPwd = data.internetLoginPwd;
                        $scope.addData.serverIp = data.serverIp;
                        $scope.addData.serverPort = data.serverPort;
                        $scope.addData.loginUser = data.loginUser;
                        $scope.addData.loginPwd = data.loginPwd;
                        $scope.addData.mobileCorp = data.mobileCorp;
                        $scope.addData.desc = data.desc;
                        $scope.addData.signType = data.signType;
                        $scope.addData.maxFlow = data.maxFlow;
                    })
                } else {
                    $scope.addData = {
                        c: '',
                        gateLinkName: '',
                        spNumber: '',
                        corpId: '',
                        linkNum: '',
                        status: '1',
                        specialIp: '',
                        specialPort: '',
                        specialLoginUser: '',
                        specialLoginPwd: '',
                        internetIp: '',
                        internetPort: '',
                        internetLoginUser: '',
                        internetLoginPwd: '',
                        serverIp: '',
                        serverPort: '',
                        loginUser: '',
                        loginPwd: '',
                        mobileCorp: '1',
                        desc: '',
                        signType: '0',
                        maxFlow: ''
                    }

                }
            };

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '通道参数说明不能为空');
                    return
                }
                if (!App.regEx($scope.addData.specialIp, 'ip')) {
                    App.alert('专线ip格式不正确');
                    return
                }
                if (!App.regEx($scope.addData.internetIp, 'ip')) {
                    App.alert('互联网ip格式不正确');
                    return
                }
                if (!App.regEx($scope.addData.serverIp, 'ip')) {
                    App.alert('短信平台ip格式不正确');
                    return
                }
                if(!$scope.addData.maxFlow && $scope.addData.maxFlow !== 0) {
                    return App.alert('最大速率不能为空');
                }
                if($scope.addData.maxFlow < 0) {
                    return App.alert('最大速率不能小于0');
                }
                if($scope.addData.maxFlow > 5000) {
                    return App.alert('最大速率不能超过5000');
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('gateDef/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            $scope.downData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('gateDef/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            $scope.downData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除记录
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/gateDef/delete', {
                    'gateLinkId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        $scope.downData();
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };

        } else {

            location.href = '#/forbid';
        }
    });
});
//========短信签名管理==========//
app.controller('smsBsManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsBsManage', function (data) {
        if (data.data.isSuccess) {
            //初始化
            $scope.searchData = {
                serviceCode: '',
                srvNode: '',
                status: '',
                signPos: ''
                //短信前后缀暂时没有
            };


            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
                //短信级联
                $scope.getSms = function () {
                    $scope.searchData.serviceCode = "";
                    MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                        "svrNode": $scope.searchData.srvNode
                    }, function (data) {
                        $scope.listData2 = data;
                    })
                }
            })



            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/smSign/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }

                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/smSign/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('smSign/changeStatus', {
                    'recId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'recId': '',
                'signContent': '',
                'status': '1',
                'desc': '',
                'acceptMo': '',
                'serviceCode': '',
                'srvNode': '',
                'serviceName': '',
                'svrNodeName': '',
                'signPos': '0'
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('smSign/toUpdate', {
                        'recId': code
                    }, function (data) {

                        //获取级联列表
                        MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                            'svrNode': data.srvNode
                        }, function (data) {
                            $scope.serviceList = data;
                        })

                        $scope.addData.signPos = data.signPos;
                        $scope.addData.recId = data.recId;
                        $scope.addData.signContent = data.signContent;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                        $scope.addData.acceptMo = data.acceptMo;
                        $scope.addData.serviceName = data.serviceName;
                        $scope.addData.svrNodeName = data.svrNodeName;
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.srvNode = data.srvNode;
                    })
                } else {
                    $scope.addData = {
                        'recId': '',
                        'signContent': '',
                        'status': '1',
                        'desc': '',
                        'acceptMo': '',
                        'serviceCode': '',
                        'srvNode': '',
                        'serviceName': '',
                        'svrNodeName': '',
                        'signPos': '0'
                    }

                }
            }

            //修改和添加时的下拉
            $scope.selectSvrNode = function () {
                $scope.addData.serviceCode = '';
                if ($scope.addData.srvNode == '') {
                    $scope.addData.serviceCode = '';
                    return
                }
                MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                    'svrNode': $scope.addData.srvNode
                }, function (data) {
                    $scope.serviceList = data;
                })
            }

            //添加和修改数据
            $scope.editSave = function () {
                var textarea = document.querySelectorAll(".modal-body textarea")
                var isSave = true
                for (var i = 0; i < textarea.length; i++) {
                    if (textarea[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(textarea)
                    return
                }
                // if($scope.addData.desc==''){
                //   App.promptOne(document.querySelector('#desc'),'通道参数说明不能为空');
                //   return
                // }

                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('smSign/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('smSign/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/smSign/delete', {
                    'recId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                });

            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };

            //搜索
            $scope.search = function () {
                if ($scope.searchData.srvNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
        } else {

            location.href = '#/forbid';
        }
    });

});
//========错误码管理==========//
app.controller('errorCodemManagement', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'errorCodemManagement', function (data) {
        if (data.data.isSuccess) {
            //错误码下拉框列表
            MyFactory.PostAjax('dicDef/getByDicName', {
                'dicName': 'errFromType'
            }, function (data) {
                $scope.errorListData = data;
            })
            //初始化
            $scope.searchData = {
                errCode: '',
                errMsg: '',
                fromType: '',
                errType: '',
                status: ''
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/errorMng/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/errorMng/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);


            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('errorMng/changeStatus', {
                    'recId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'recId': '',
                'fromType': '',
                'errType': '1',
                'errCode': '',
                'errMsg': '',
                'status': '0',
                'innerCode': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('errorMng/toUpdate', {
                        'recId': code
                    }, function (data) {
                        $scope.addData.recId = data.recId;
                        $scope.addData.fromType = data.fromType;
                        $scope.addData.errType = data.errType;
                        $scope.addData.status = data.status;
                        // $scope.addData.errCode=data.errCode;pingtaicuowuma
                        $scope.addData.errMsg = data.errMsg;
                        $scope.addData.innerCode = data.innerCode;
                        $scope.addData.errCode = data.errCode;
                        $scope.addData.desc = data.desc;
                    })
                } else {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'recId': '',
                        'fromType': '',
                        'errType': '',
                        'errCode': '',
                        'errMsg': '',
                        'status': '0',
                        'innerCode': ''
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true;
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.errMsg == '') {
                    App.promptOne(document.querySelector('#desc'), '说明不能为空');
                    return
                }
                if (parseInt($scope.addData.innerCode) > 126) {
                    App.alert('错误码不能超过126');
                    return
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('errorMng/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('errorMng/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/errorMng/delete', {
                    'recId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })

            };
            //导出表格信息
            $scope.outExcel = function () {
                $('#form').submit();
            };
        } else {

            location.href = '#/forbid';
        }
    });
});



//========禁发时段管理==========//
app.controller('forbiddentimeManage', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'forbiddentimeManage', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.setSms($scope);

            //搜索数据模型
            $scope.searchData = {
                svrNode: '',
                serviceCode: '',
                status: ''
            }

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/forbidRule/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/forbidRule/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('/forbidRule/changeStatus', {
                    'forbidRuleId': code,
                    'status': status
                }, function (data) {

                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //====添加tr和编辑tr====//
            $scope.addData = {
                'forbidRuleName': '',
                'svrNodeName': '',
                'startTime': '',
                'endTime': '',
                'serviceName': '',
                'status': '',
                'desc': '',
                'acceptMo': ''
            }




            $scope.editTr = function (value, id) {
                $scope.popup = value;
                if ($scope.popup == '添加') {
                    $scope.addData = {
                        'forbidRuleName': '',
                        'svrNode': '',
                        'startTime': '',
                        'endTime': '',
                        'serviceCode': '',
                        'status': '1',
                        'desc': ''
                    }
                    $scope.timeData = {
                        'startTimehour': '',
                        'startTimesecnd': '',
                        'endTimehour': '',
                        'endTimesecnd': '',
                    }

                } else {
                    $scope.editId = id;

                    MyFactory.PostAjax('/forbidRule/toUpdate', {
                        'forbidRuleId': $scope.editId
                    }, function (data) {
                        //获取级联数据
                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode)

                        $scope.addData.forbidRuleId = data.forbidRuleId;
                        $scope.addData.forbidRuleName = data.forbidRuleName;
                        $scope.addData.svrNode = data.svrNode;
                        $(".startTimehour").val(Math.floor(data.startTime));
                        $(".startTimesecnd").val(Math.floor((data.startTime - Math.floor(data.startTime)) * 60));
                        $(".endTimehour").val(Math.floor(data.endTime));
                        $(".endTimesecnd").val(Math.floor((data.endTime - Math.floor(data.endTime)) * 60));

                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                    })
                }
            };

            //修改和保存级联
            MyFactory.changeSvrNode($scope);

            //保存修改和添加的数据
            $scope.editSave = function () {
                if ($scope.popup == '修改') {
                    var input = $('.modal-body input');
                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return;
                    }
                    $scope.addData.startTime = parseInt($(".startTimehour").val()) + Math.floor(($(".startTimesecnd").val() / 60) * 100) / 100;
                    $scope.addData.endTime = parseInt($(".endTimehour").val()) + Math.floor(($(".endTimesecnd").val() / 60) * 100) / 100;


                    MyFactory.PostAjax('/forbidRule/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                        $scope.upData();
                    })

                } else if ($scope.popup == '添加') {

                    $scope.addData.startTime = parseInt($(".startTimehour").val()) + Math.floor(($(".startTimesecnd").val() / 60) * 100) / 100;
                    // $scope.addData.startTime=addData.startTimehour+Math.floor((addData.startTimesecnd/60)*100)/100;
                    $scope.addData.endTime = parseInt($(".endTimehour").val()) + Math.floor(($(".endTimesecnd").val() / 60) * 100) / 100;
                    //$scope.addData.endTime=addData.endTimehour+Math.floor((addData.endTimesecnd/60)*100)/100;
                    var input = $('.modal-body input');
                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return;
                    }
                    MyFactory.PostAjax('/forbidRule/save', $scope.addData, function (data) {

                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }

                    })

                    //MyFactory.runAddOrEdit($scope);
                    $scope.upData();
                }

            }
            //=====添加参数=====//
            $scope.addConfig = function () {
                $scope.addData.prgExtInfos.push({
                    'recId': '',
                    'paramName': '',
                    'paramNameCn': '',
                    'paramValue': ''
                });
            }
            ///====删除tr====//
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/forbidRule/delete', {
                    'forbidRuleId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })

            };



            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };

            //搜索
            $scope.search = function () {
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//========重复过滤管理管理==========//
app.controller('repeatFilterManage', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'repeatFilterManage', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.setSms($scope);

            //搜索数据模型
            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
            }

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/repeatRule/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    if (callback) {
                        callback();
                    }
                    $scope.loaded = false;

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/repeatRule/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();


            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('/repeatRule/changeStatus', {
                    'repeatRuleId': code,
                    'status': status
                }, function (data) {

                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //====添加tr和编辑tr====//
            $scope.addData = {
                'repeatRuleName': '',
                'serviceCode': '',
                'svrNode': '',
                'timeLen': '',
                'smSeq': true,
                'serviceCodeFlag': false,
                'smFlag': false,
                'userFlag': false,
                'status': 1,
                'desc': ''
            }
            $scope.editTr = function (value, id) {
                $scope.popup = value;

                if ($scope.popup == '添加') {
                    $scope.addData = {
                        'repeatRuleName': '',
                        'serviceCode': '',
                        'svrNode': '',
                        'timeLen': '',
                        'smSeq': true,
                        'serviceCodeFlag': false,
                        'smFlag': false,
                        'userFlag': false,
                        'status': '1',
                        'desc': ''
                    }

                } else {
                    $scope.editId = id;

                    MyFactory.PostAjax('/repeatRule/toUpdate', {
                        'repeatRuleId': $scope.editId
                    }, function (data) {

                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode)
                        $scope.addData = {
                            'repeatRuleId': '',
                            'repeatRuleName': '',
                            'serviceCode': '',
                            'svrNode': '',
                            'timeLen': '',
                            'smSeq': true,
                            'serviceCodeFlag': '',
                            'smFlag': '',
                            'userFlag': '',
                            'status': '',
                            'desc': ''
                        };
                        $scope.addData.repeatRuleId = data.repeatRuleId;
                        $scope.addData.repeatRuleName = data.repeatRuleName;
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.svrNode = data.svrNode;
                        $scope.addData.timeLen = data.timeLen;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                        $scope.addData.smSeq = true;
                        if (data.serviceCodeFlag == 1) {
                            $scope.addData.serviceCodeFlag = true;
                        } else {
                            $scope.addData.serviceCodeFlag = false;
                        }
                        if (data.smFlag == 1) {
                            $scope.addData.smFlag = true;
                        } else {
                            $scope.addData.smFlag = false;
                        }
                        if (data.userFlag == 1) {
                            $scope.addData.userFlag = true;
                        } else {
                            $scope.addData.userFlag = false;
                        }

                    })
                }
            };

            //保存和修改下来级联
            MyFactory.changeSvrNode($scope);

            //保存添加和修改
            $scope.editSave = function () {
                if ($scope.popup == '修改') {
                    $scope.addData.smSeq = 1;
                    if ($scope.addData.serviceCodeFlag == true) {
                        $scope.addData.serviceCodeFlag = 1;
                    } else {
                        $scope.addData.serviceCodeFlag = 0;
                    }
                    if ($scope.addData.smFlag == true) {
                        $scope.addData.smFlag = 1;
                    } else {
                        $scope.addData.smFlag = 0;
                    }
                    if ($scope.addData.userFlag == true) {
                        $scope.addData.userFlag = 1;
                    } else {
                        $scope.addData.userFlag = 0;
                    }
                    var input = $('.modal-body input[type=text]');
                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return;
                    }
                    MyFactory.PostAjax('/repeatRule/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                        $scope.upData();
                    })

                } else if ($scope.popup == '添加') {
                    var input = $('.modal-body [ type="text"]');
                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return;
                    }
                    //修改四个剔重返回值
                    $scope.addData.smSeq = 1;
                    if ($scope.addData.serviceCodeFlag == true) {
                        $scope.addData.serviceCodeFlag = 1;
                    } else {
                        $scope.addData.serviceCodeFlag = 0;
                    }
                    if ($scope.addData.smFlag == true) {
                        $scope.addData.smFlag = 1;
                    } else {
                        $scope.addData.smFlag = 0;
                    }
                    if ($scope.addData.userFlag == true) {
                        $scope.addData.userFlag = 1;
                    } else {
                        $scope.addData.userFlag = 0;
                    }
                    if ($(".serviceCode").val() == "") {
                        $scope.addData.svrNode = "";
                        $scope.addData.serviceCode = "";
                    }
                    MyFactory.PostAjax('/repeatRule/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add1').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }


                    })


                    $scope.upData();
                }

            }

            ///====删除tr====//
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/repeatRule/delete', {
                    'repeatRuleId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {

                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })

            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };

            $scope.search = function () {
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//========错误码导入==========//
app.controller('errorCodeImport', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'errorCodeImport', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                fileName: '',
                userName: '',
                auditStatus: '',
                fileType: '错误码'
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('uploadFile/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'uploadFile/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();


            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //审核
            $scope.changeStstus = function (index, id) {
                $scope.sendData = {
                    'auditStatus': '1',
                    'fileId': ''
                }
                $scope.sendAjax = function () {
                    MyFactory.PostAjax('/uploadFile/audit', {
                        'fileId': id,
                        'auditStatus': $scope.sendData.auditStatus
                    }, function (data) {

                        if (data.isSuccess == true) {
                            //         $scope.result[index].auditStatus= auditStatus;
                            if ($scope.sendData.auditStatus === '0') {
                                $scope.result[index].auditStatusStr = '待审查';
                            }
                            if ($scope.sendData.auditStatus === '1') {
                                $scope.result[index].auditStatusStr = '审查通过';
                            }
                            if ($scope.sendData.auditStatus === '2') {
                                $scope.result[index].auditStatusStr = '审查不通过';
                            }
                            App.alert(data.msg, function () {
                                $('#audit').modal('hide');
                            });
                            $scope.upData();
                        }
                        if (data.isSuccess == false) {
                            App.alert(data.msg)
                        }
                    })
                }
            }
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };



            $scope.qix = function () {
                $("#file").val("");
            }

            $scope.statusLoad = {
                'display': 'none'
            };
            $scope.upfile = function () {
                $scope.loadStatus = '导入';
                $scope.statusLoad = {
                    'display': 'block'
                };
                $("#uploadForm").ajaxSubmit({
                    url: "uploadFile/upload",
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    success: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg), function () {
                            $("#import").modal('hide');
                            $scope.upData();
                        });
                    },
                    error: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg));

                    }
                });
            }
            $scope.daoru = function () {
                var file = $("#file").val();
                if (file == "") {
                    App.alert("上传文件不能为空")
                } else {
                    var postfix = /\.[^\.]+/.exec(file)[0];
                    var txtcsvxls = $("#txtcsvxls").val();
                    if ((txtcsvxls == "txt") && (postfix == ".txt")) {
                        $scope.upfile()
                    } else if ((txtcsvxls == "csv") && (postfix == ".csv")) {
                        $scope.upfile()
                    } else if ((txtcsvxls == "xlsx") && (postfix == ".xlsx")) {
                        $scope.upfile()
                    } else {
                        App.alert("文件格式不相符，请重新导入文件")
                    }
                }
            }
        } else {

            location.href = '#/forbid';
        }
    });
});
//========错误码导入明细==========//
app.controller('errorCodeImportDetail', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'errorCodeImportDetail', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                fileName: '',
                userName: '',
                status: '',
                startDate: '',
                endDate: '',
                fileType: '错误码'
            };
            MyFactory.Date($scope, '#erroDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/inputLine/query', $scope.searchData,
                    function (data) {

                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }

                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/inputLine/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })


                    }
                );
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
            //时间调用
            $('#erroDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#erroDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
        } else {

            location.href = '#/forbid';
        }
    });

});
//========敏感词管理==========//
app.controller('sensitiveWordManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'sensitiveWordManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                senName: '',
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/sensitive/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/sensitive/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('sensitive/changeStatus', {
                    'senId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };
            //添加或者编辑挂载数据
            $scope.addData = {
                'senId': '',
                'senName': '',
                'status': '1',
                'desc': '',
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('sensitive/toUpdate', {
                        'senId': code
                    }, function (data) {

                        //$scope.addData=data;
                        $scope.addData.senId = data.senId;
                        $scope.addData.senName = data.senName;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                    })
                } else {
                    $scope.addData = {
                        'senId': '',
                        'senName': '',
                        'status': '1',
                        'desc': '',
                    }
                }
            }
            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '说明不能为空');
                    return
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('sensitive/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('sensitive/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/sensitive/delete', {
                    'senId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                };

                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
        } else {

            location.href = '#/forbid';
        }
    });
});
//========黑名单导入==========//
app.controller('blackListimport', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'blackListimport', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                startDate: '',
                endDate: '',
                fileName: '',
                userName: '',
                fileType: '黑名单'
                // mobile:''暂时没有
            };


            //上传导入文件
            $scope.statusLoad = {
                'display': 'none'
            };
            $scope.upfile = function () {
                $scope.loadStatus = '导入';
                $scope.statusLoad = {
                    'display': 'block'
                };
                $("#uploadForm").ajaxSubmit({
                    url: "uploadFile/upload",
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    success: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg), function () {
                            $("#add1").modal('hide');
                            $scope.upData();
                        });
                    },
                    error: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg));

                    }
                });
            }

            MyFactory.Date($scope, '#blackListDate', 'startDate', 'endDate');
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('/uploadFile/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/uploadFile/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
                $scope.selectAll = function () {
                    if ($scope.select_all) {
                        $scope.checked = [];
                        angular.forEach($scope.result, function (i) {
                            i.checked = true;
                            $scope.checked.push(i.fileId);
                        })
                    } else {
                        angular.forEach($scope.result, function (i) {
                            i.checked = false;
                            $scope.checked = [];
                        })
                    }

                };
                $scope.selectOne = function () {
                    $scope.checked = [];
                    angular.forEach($scope.result, function (i) {
                        var index = $scope.checked.indexOf(i.fileId);
                        if (i.checked && index === -1) {
                            $scope.checked.push(i.fileId);
                        } else if (!i.checked && index !== -1) {
                            $scope.checked.splice(index, 1);
                        };
                    })
                    if ($scope.result.length === $scope.checked.length) {
                        $scope.select_all = true;
                    } else {
                        $scope.select_all = false;
                    }

                }
                //生效、失效、删除、导入
                $scope.changeStstus = function (value) {
                    var arrData = [];
                    angular.forEach($scope.result, function (i) {
                        if (i.checked == true) {
                            arrData.push(i.fileId);
                        }
                    })
                    var str = arrData.join(',');
                    if (value == "生效") {
                        if (str != "") {
                            MyFactory.PostAjax('uploadFile/changeStatus', {
                                'fileIds': str,
                                'status': '1',
                                'fileType': '黑名单'
                            }, function (data) {
                                if (data.isSuccess == false) {
                                    App.alert(data.msg)
                                } else if (data.isSuccess == true) {
                                    $scope.select_all = false;
                                    App.alert(data.msg)
                                }
                                $scope.upData()
                            })
                        } else {
                            App.alert("请至少选择一个黑名单号码")
                        }

                    }
                    if (value == "失效") {
                        if (str != "") {
                            MyFactory.PostAjax('uploadFile/changeStatus', {
                                'fileIds': str,
                                'status': '0',
                                'fileType': '黑名单'
                            }, function (data) {
                                if (data.isSuccess == false) {
                                    App.alert(data.msg)
                                } else if (data.isSuccess == true) {
                                    $scope.select_all = false;
                                    App.alert(data.msg)
                                }
                                $scope.upData()
                            })
                        } else {
                            App.alert("请至少选择一个黑名单号码")
                        }

                    }
                    if (value == "删除") {
                        if (str != "") {
                            $("#add").attr("data-target", "#delete")

                        } else {
                            App.alert("请至少选择一个黑名单号码");
                            $("#add").attr("data-target", "")
                        }

                    }
                    if (value == "key") {
                        MyFactory.PostAjax('uploadFile/delete', {
                            'fileIds': str,
                            'fileType': '黑名单'
                        }, function (data) {
                            if (data.isSuccess == false) {
                                App.alert(data.msg)
                            } else if (data.isSuccess == true) {
                                for (var i = 0; i < arrData.length; i++) {
                                    $scope.result.splice(i, 1);
                                }
                                $scope.upData();
                                App.alert(data.msg)
                            }

                        })
                    }


                }
            }

            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            $scope.qix = function () {
                $("#file").val("");
            }
            $scope.daoru = function () {
                var file = $("#file").val();
                if (file == "") {
                    App.alert("上传文件不能为空")
                } else {
                    var postfix = /\.[^\.]+/.exec(file)[0];
                    var txt = $("#txt").prop("checked");
                    var csv = $("#csv").prop("checked");
                    var excel = $("#excel").prop("checked");

                    if ((txt == true) && (postfix == ".txt")) {
                        $scope.upfile()
                    } else if ((csv == true) && (postfix == ".csv")) {

                        $scope.upfile()
                    } else if ((excel == true) && (postfix == ".xlsx" || postfix == ".xls")) {

                        $scope.upfile()
                    } else {
                        App.alert("文件格式不相符，请重新导入文件")
                    }
                }
            }

            function progressHandlingFunction(e) {
                if (e.lengthComputable) {
                    $('progress').attr({
                        value: e.loaded,
                        max: e.total
                    });
                }
            }

            //导出表格信息
            $scope.outExcel = function () {
                $('#form').submit();
            };

            //时间调用
            $('#blackListDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#blackListDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
            //查询
            $scope.search = function (e) {

                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#blackListDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $scope.upData();
                    }

                } else {
                    var strData = $("#blackListDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $scope.upData();
                }


            }
        } else {

            location.href = '#/forbid';
        }
    });
});



//========黑名单列表==========//
app.controller('blackListManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'blackListManage', function (data) {
        if (data.data.isSuccess) {
            //搜索
            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
                'blackUser': '',
                'status': ''
            }

            //业务端下拉列表
            MyFactory.setSms($scope);

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/blackUse/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/blackUse/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('blackUse/changeStatus', {
                    'recId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '生效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };
            //添加或者编辑挂载数据
            $scope.addData = {
                'recId': '',
                'svrNode': '',
                'status': '1',
                'desc': '',
                'serviceCode': '',
                'blackUser': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('blackUse/toUpdate', {
                        'recId': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode);
                        $scope.addData.recId = data.recId;
                        $scope.addData.svrNode = data.svrNode;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.blackUser = data.blackUser;
                    })
                } else {
                    $scope.addData = {
                        'recId': '',
                        'svrNode': '',
                        'status': '1',
                        'desc': '',
                        'serviceCode': '',
                        'blackUser': ''
                    }
                }
            }

            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            })
            //短信类型下拉列表
            MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                $scope.listData2 = data;
            })

            //添加和修改级联
            MyFactory.changeSvrNode($scope);

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '说明不能为空');
                    return
                }

                //信息无误开始请求
                if ($scope.popup == '修改') {

                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($("#phone").val())) {
                        App.alert('请输入有效的手机号码！');
                        return false;
                    }
                    MyFactory.PostAjax('blackUse/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($("#phone").val())) {
                        App.alert('请输入有效的手机号码！');
                        return false;
                    }
                    MyFactory.PostAjax('blackUse/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/blackUse/delete', {
                    'recId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        $scope.result.splice($scope.deleteIndex, 1);
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };

        } else {

            location.href = '#/forbid';
        }
    });
});
//========红名单导入============//
app.controller('redListimport', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'redListimport', function (data) {
        if (data.data.isSuccess) {
            //搜索
            $scope.searchData = {
                startDate: '',
                endDate: '',
                fileName: '',
                userName: '',
                fileType: '红名单'
            }

            MyFactory.Date($scope, '#redListDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/uploadFile/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/uploadFile/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })
                    }
                );

                $scope.selectAll = function () {
                    if ($scope.select_all) {
                        $scope.checked = [];
                        angular.forEach($scope.result, function (i) {
                            i.checked = true;
                            $scope.checked.push(i.fileId);
                        })
                    } else {
                        angular.forEach($scope.result, function (i) {
                            i.checked = false;
                            $scope.checked = [];
                        })
                    }

                };
                $scope.selectOne = function () {
                    $scope.checked = [];
                    angular.forEach($scope.result, function (i) {
                        var index = $scope.checked.indexOf(i.fileId);
                        if (i.checked && index === -1) {
                            $scope.checked.push(i.fileId);
                        } else if (!i.checked && index !== -1) {
                            $scope.checked.splice(index, 1);
                        };
                    })
                    if ($scope.result.length === $scope.checked.length) {
                        $scope.select_all = true;
                    } else {
                        $scope.select_all = false;
                    }

                }
                //生效、失效、删除、导入
                $scope.changeStstus = function (value) {
                    var arrData = [];
                    angular.forEach($scope.result, function (i) {
                        if (i.checked == true) {
                            arrData.push(i.fileId);
                        }
                    })
                    var str = arrData.join(',');
                    if (value == "生效") {
                        if (str != "") {
                            MyFactory.PostAjax('uploadFile/changeStatus', {
                                'fileIds': str,
                                'status': '1',
                                'fileType': '红名单'
                            }, function (data) {
                                if (data.isSuccess == false) {
                                    App.alert(data.msg)
                                } else if (data.isSuccess == true) {
                                    $scope.select_all = false;
                                    App.alert(data.msg)
                                }
                                $scope.upData()
                            })
                        } else {
                            App.alert("请至少选择一个红名单号码")
                        }

                    }
                    if (value == "失效") {
                        if (str != "") {
                            MyFactory.PostAjax('uploadFile/changeStatus', {
                                'fileIds': str,
                                'status': '0',
                                'fileType': '红名单'
                            }, function (data) {
                                if (data.isSuccess == false) {
                                    App.alert(data.msg)
                                } else if (data.isSuccess == true) {
                                    $scope.select_all = false;
                                    App.alert(data.msg)
                                }
                                $scope.upData()
                            })
                        } else {
                            App.alert("请至少选择一个红名单号码")
                        }

                    }
                    if (value == "删除") {
                        if (str != "") {
                            $("#add").attr("data-target", "#delete")

                        } else {
                            App.alert("请至少选择一红名单号码");
                            $("#add").attr("data-target", "")
                        }

                    }
                    if (value == "key") {
                        MyFactory.PostAjax('/uploadFile/delete', {
                            'fileIds': str,
                            'fileType': '红名单'
                        }, function (data) {
                            if (data.isSuccess == false) {
                                App.alert(data.msg)
                            } else if (data.isSuccess == true) {
                                for (var i = 0; i < arrData.length; i++) {
                                    $scope.result.splice(i, 1);
                                }
                                $scope.upData();
                                App.alert(data.msg)
                            }

                        })
                    }


                }
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            $scope.qix = function () {
                $("#file").val("");
            }
            $scope.daoru = function () {
                var file = $("#file").val();
                if (file == "") {
                    App.alert("上传文件不能为空")
                } else {
                    var postfix = /\.[^\.]+/.exec(file)[0];
                    var txt = $("#txt").prop("checked");
                    var csv = $("#csv").prop("checked");
                    var excel = $("#excel").prop("checked");

                    if ((txt == true) && (postfix == ".txt")) {
                        $scope.upfile()
                    } else if ((csv == true) && (postfix == ".csv")) {

                        $scope.upfile()
                    } else if ((excel == true) && (postfix == ".xlsx" || postfix == ".xls")) {

                        $scope.upfile()
                    } else {
                        App.alert("文件格式不相符，请重新导入文件")
                    }
                }
            }
            //上传导入文件
            $scope.statusLoad = {
                'display': 'none'
            };
            $scope.upfile = function () {
                $scope.loadStatus = '导入';
                $scope.statusLoad = {
                    'display': 'block'
                };
                $("#uploadForm").ajaxSubmit({
                    url: "uploadFile/upload",
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    success: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg), function () {
                            $("#add1").modal('hide');
                            $scope.upData();
                        });
                    },
                    error: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg));

                    }
                });
            }

            function progressHandlingFunction(e) {
                if (e.lengthComputable) {
                    $('progress').attr({
                        value: e.loaded,
                        max: e.total
                    });
                }
            }

            //导出表格信息
            $scope.outExcel = function () {
                $('#form').submit();
            };

            //时间调用
            $('#redListDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#redListDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            //查询
            $scope.search = function (e) {

                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#redListDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $scope.upData();
                    }

                } else {
                    var strData = $("#redListDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $scope.upData();
                }
            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//========红名单列表 =============//
app.controller('redListManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'redListManage', function (data) {
        if (data.data.isSuccess) {
            //搜索
            $scope.searchData = {
                'svrNode': '',
                'phone': '',
                'status': ''
            }

            //业务端下拉列表
            MyFactory.setSms($scope);

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/redUserList/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/redUserList/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('/redUserList/changeStatus', {
                    'recId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '生效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };
            //添加或者编辑挂载数据
            $scope.addData = {
                'recId': '',
                'svrNode': '',
                'status': '1',
                'remark': '',
                'phone': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('/redUserList/toUpdate', {
                        'recId': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode);
                        $scope.addData.recId = data.recId;
                        $scope.addData.svrNode = data.svrNode;
                        $scope.addData.status = data.status;
                        $scope.addData.remark = data.remark;
                        $scope.addData.phone = data.phone;
                    })
                } else {
                    $scope.addData = {
                        'recId': '',
                        'svrNode': '',
                        'status': '1',
                        'remark': '',
                        'phone': ''
                    }
                }
            }

            //添加和修改级联
            MyFactory.changeSvrNode($scope);

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '说明不能为空');
                    return
                }

                if ($scope.addData.svrNode == '') {
                    App.promptOne(document.querySelector('#svrNode'), '业务端不能为空');
                    return
                }

                //信息无误开始请求
                if ($scope.popup == '修改') {

                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($("#phone").val())) {
                        App.alert('请输入有效的手机号码！');
                        return false;
                    }
                    MyFactory.PostAjax('/redUserList/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($("#phone").val())) {
                        App.alert('请输入有效的手机号码！');
                        return false;
                    }
                    MyFactory.PostAjax('/redUserList/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/redUserList/delete', {
                    'recId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        $scope.result.splice($scope.deleteIndex, 1);
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
        } else {

            location.href = '#/forbid';
        }
    });

})
//========无效用户列表==========//
app.controller('invalidUserManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'invalidUserManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'invalidUser': '',
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/invalidUse/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/invalidUse/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //添加或者编辑挂载数据
            $scope.addData = {
                'recId': '',
                'invalidUser': '',
                'desc': '',
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('invalidUse/toUpdate', {
                        'recId': code
                    }, function (data) {
                        //$scope.addData=data;
                        $scope.addData.recId = data.recId;
                        $scope.addData.invalidUser = data.invalidUser;
                        $scope.addData.desc = data.desc;
                    })
                } else {
                    $scope.addData = {
                        'recId': '',
                        'invalidUser': '',
                        'desc': '',
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {


                if ($scope.popup == '修改') {
                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($(".invalidUser").val())) {
                        App.alert('请输入有效的手机号码！');
                        $scope.addData.invalidUser = "";
                        return false;
                    }
                    MyFactory.PostAjax('invalidUse/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                if (data.isSuccess == true) {
                                    $('#add').modal('hide');
                                }

                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($(".invalidUser").val())) {
                        App.alert('请输入有效的手机号码！');
                        $scope.addData.invalidUser = "";
                        return false;
                    }
                    MyFactory.PostAjax('invalidUse/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/invalidUse/delete', {
                    'recId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
        } else {

            location.href = '#/forbid';
        }
    });

});
//========无效用户导入==========//
app.controller('invalidUserimport', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'invalidUserimport', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                startDate: '',
                endDate: '',
                fileName: '',
                userName: '',
                fileType: '无效用户'
                // mobile:''暂时没有
            };
            MyFactory.Date($scope, '#invalidDate', 'startDate', 'endDate');
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('/uploadFile/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/uploadFile/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            $scope.qix = function () {
                $("#file").val("");
            }
            $scope.daoru = function () {
                var file = $("#file").val();
                if (file == "") {
                    App.alert("上传文件不能为空")
                } else {
                    var postfix = /\.[^\.]+/.exec(file)[0];
                    var txt = $("#txt").prop("checked");
                    var csv = $("#csv").prop("checked");
                    var excel = $("#excel").prop("checked");

                    if ((txt == true) && (postfix == ".txt")) {
                        $scope.upfile()
                    } else if ((csv == true) && (postfix == ".csv")) {

                        $scope.upfile()
                    } else if ((excel == true) && (postfix == ".xlsx" || postfix == ".xls")) {

                        $scope.upfile()
                    } else {
                        App.alert("文件格式不相符，请重新导入文件")
                    }
                }
            }

            //复选框全选
            $scope.check = function () {
                for (var i = 0; i < $(".check").length; i++) {
                    if ($(".check").eq(i).prop("checked") == false) {
                        $("#all").prop("checked", "")
                    }
                }
            }

            //生效、失效、删除、导入
            $scope.changeStstus = function (value) {
                var arrData = [];
                angular.forEach($scope.result, function (i, index) {
                    var check = $("#appList .check").eq(index).prop("checked");

                    if (check == true) {
                        arrData.push(i.fileId);

                    }
                })
                var str = arrData.join(',');
                if (value == "生效") {
                    if (str != "") {
                        MyFactory.PostAjax('uploadFile/changeStatus', {
                            'fileIds': str,
                            'status': '1',
                            'fileType': '无效用户'
                        }, function (data) {
                            if (data.isSuccess == false) {
                                App.alert(data.msg)
                            } else if (data.isSuccess == true) {
                                App.alert(data.msg)
                            }
                            $scope.upData()
                            $scope.all = false
                        })
                    } else {
                        App.alert("请至少选择一个无效用户号码")
                    }

                }
                if (value == "失效") {
                    if (str != "") {
                        MyFactory.PostAjax('uploadFile/changeStatus', {
                            'fileIds': str,
                            'status': '0',
                            'fileType': '无效用户'
                        }, function (data) {
                            if (data.isSuccess == false) {
                                App.alert(data.msg)
                            } else if (data.isSuccess == true) {
                                App.alert(data.msg)
                            }
                            $scope.upData()
                            $scope.all = false;
                        })
                    } else {
                        App.alert("请至少选择一个无效用户号码")
                    }


                }
                if (value == "删除") {
                    if (str != "") {
                        $("#add").attr("data-target", "#delete")

                    } else {
                        App.alert("请至少选择一个无效用户号码");
                        $("#add").attr("data-target", "")
                    }

                }
                if (value == "key") {
                    MyFactory.PostAjax('uploadFile/delete', {
                        'fileIds': str,
                        'fileType': '无效用户'
                    }, function (data) {
                        if (data.isSuccess == false) {
                            App.alert(data.msg)
                        } else if (data.isSuccess == true) {
                            for (var i = 0; i < arrData.length; i++) {
                                $scope.result.splice(i, 1);
                            }
                            $scope.upData();
                            $scope.all = false;
                            App.alert(data.msg)
                        }

                    })
                }


            }
            //初始化导入文件
            $scope.qix = function () {
                $("#file").val("");
            }

            $scope.statusLoad = {
                'display': 'none'
            };
            $scope.upfile = function () {
                $scope.loadStatus = '导入';
                $scope.statusLoad = {
                    'display': 'block'
                };
                $("#uploadForm").ajaxSubmit({
                    url: "uploadFile/upload",
                    type: "POST",
                    contentType: "application/x-www-form-urlencoded; charset=utf-8",
                    success: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        }
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg), function () {
                            if (data.success == true) {
                                $("#add1").modal('hide');
                                $scope.upData();
                            }

                        });
                    },
                    error: function (data) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        var data = JSON.parse(data);
                        data = data[0];
                        App.alert(decodeURIComponent(data.msg));

                    }
                });
            }
            $scope.daoru = function () {
                var file = $("#file").val();
                if (file == "") {
                    App.alert("上传文件不能为空")
                } else {
                    var postfix = /\.[^\.]+/.exec(file)[0];
                    var txt = $("#txt").prop("checked");
                    var csv = $("#csv").prop("checked");
                    var excel = $("#excel").prop("checked");
                    if ((txt == true) && (postfix == ".txt")) {
                        $scope.upfile()
                    } else if ((csv == true) && (postfix == ".csv")) {
                        $scope.upfile()
                    } else if ((excel == true) && (postfix == ".xls" || postfix == ".xlsx")) {
                        $scope.upfile()
                    } else {
                        App.alert("文件格式不相符，请重新导入文件")
                    }
                }

            }

            //时间调用
            $('#invalidDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#invalidDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        var strData = $("#invalidDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10)
                        $scope.searchData.endDate = strData.substring(12)
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $scope.upData();
                    }
                } else {
                    var strData = $("#invalidDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10)
                    $scope.searchData.endDate = strData.substring(12)
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $scope.upData();
                }

            }
        } else {

            location.href = '#/forbid';
        }
    });
});



//========条件短信管理==========//
app.controller('conditionSmsManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'conditionSmsManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
            }
            //业务端下拉列表
            MyFactory.setSms($scope);

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/affixRule/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/affixRule/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('affixRule/changeStatus', {
                    'affixRuleId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };
            //添加或者编辑挂载数据
            $scope.addData = {
                'affixRuleId': '',
                'svrNode': '',
                'serviceCode': '',
                'status': '1',
                'desc': '',
                'affixRuleName': '',
                'moSm': '',
                'affixSm': '',
                'timeLen': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('affixRule/toUpdate', {
                        'affixRuleId': code
                    }, function (data) {

                        MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                            "svrNode": data.svrNode
                        }, function (data) {
                            $scope.serviceList = data;
                        })
                        $scope.addData.svrNode = data.svrNode;
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.affixRuleId = data.affixRuleId;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                        $scope.addData.affixRuleName = data.affixRuleName;
                        $scope.addData.moSm = data.moSm;
                        $scope.addData.affixSm = data.affixSm;
                        $scope.addData.timeLen = data.timeLen;
                    })
                } else {
                    $scope.addData = {
                        'affixRuleId': '',
                        'svrNode': '',
                        'serviceCode': '',
                        'status': '1',
                        'desc': '',
                        'affixRuleName': '',
                        'moSm': '',
                        'affixSm': '',
                        'timeLen': ''
                    }

                }
            }



            //添加和修改数据级联
            $scope.getServiceCode = function () {
                $scope.addData.serviceCode = '';
                if ($scope.addData.svrNode == '') {
                    $scope.addData.serviceCode = ''
                }
                MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                    "svrNode": $scope.addData.svrNode
                }, function (data) {
                    $scope.serviceList = data;
                })
            }



            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }

                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('affixRule/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('affixRule/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/affixRule/delete', {
                    'affixRuleId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
            //搜索
            $scope.search = function () {
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
        } else {

            location.href = '#/forbid';
        }
    });

});
//========业务路由管理==========//
app.controller('businessRouteManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'businessRouteManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'serviceCode': '',
                'gateLinkId': '',
                'status': ''
            }

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/svrRouteRule/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/svrRouteRule/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();


            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //下拉
            MyFactory.PostAjax('serviceCodeDef/getAll', '', function (data) {
                $scope.listData2 = data;
            })

            MyFactory.PostAjax('gateDef/getUnusedGateByService', '', function (data) {
                $scope.showData = data;
            })

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('svrRouteRule/changeStatus', {
                    'ruleId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };
            //添加或者编辑挂载数据
            $scope.addData = {
                'ruleId': '',
                'status': '1',
                'desc': '',
                'serviceCode': '',
                'ruleName': '',
                'gateLinkId': '',
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('svrRouteRule/toUpdate', {
                        'ruleId': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode);
                        $scope.addData.ruleId = data.ruleId;
                        $scope.addData.status = data.status;
                        $scope.addData.gateLinkId = data.gateLinkId;
                        $scope.addData.desc = data.desc;
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.ruleName = data.ruleName;
                    })
                } else {
                    $scope.addData = {
                        'ruleId': '',
                        'status': '1',
                        'desc': '',
                        'serviceCode': '',
                        'ruleName': '',
                        'gateLinkId': '',
                    }

                }
            }


            $scope.selectLinkId = function () {
                if ($scope.addData.gateLinkId == '') {
                    App.promptOne(App.d('#gateLinkId'), '请选择短信通道');
                }
            }
            //添加和修改数据保存
            $scope.editSave = function () {
                if ($scope.addData.ruleName == '') {
                    App.promptOne(App.d('#ruleName'), '路由名称不能为空');
                    return
                }
                if ($scope.addData.gateLinkId == '') {
                    App.promptOne(App.d('#gateLinkId'), '请选择短信通道');
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(App.d('#desc'), '路由说明不能为空');
                    return
                }
                //信息无误开始
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('svrRouteRule/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('svrRouteRule/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/svrRouteRule/delete', {
                    'ruleId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
        } else {

            location.href = '#/forbid';
        }
    });

});
//========号段路由管理==========//
app.controller('segmentroutManage', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'segmentroutManage', function (data) {
        if (data.data.isSuccess) {
            //搜索
            $scope.searchData = {
                'province': '',
                'mobilCorp': '',
                'sectionNo': '',
                'status': '',
            }

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/userRouteRule/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/userRouteRule/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            // 运营商获取
            MyFactory.PostAjax('/dicDef/getByDicName', {
                'dicName': 'mobileCorp'
            }, function (data) {
                $scope.mobileCorpData = data;
            });

            //初始化省份
            MyFactory.PostAjax('/province/getAll', {}, function (data) {
                $scope.provinceData = data;
            });




            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('userRouteRule/changeStatus', {
                    'ruleId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };
            //添加或者编辑挂载数据
            $scope.addData = {
                'ruleId': '',
                'ruleName': '',
                'status': '1',
                'desc': '',
                'sectionNo': '',
                'province': '',
                'mobilCorp': '',
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('userRouteRule/toUpdate', {
                        'ruleId': code
                    }, function (data) {

                        $scope.addData.ruleId = data.ruleId;
                        $scope.addData.ruleName = data.ruleName;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                        $scope.addData.sectionNo = data.sectionNo;
                        $scope.addData.province = data.province;
                        $scope.addData.mobilCorp = data.mobilCorp;

                    })
                } else {
                    $scope.addData = {
                        'ruleId': '',
                        'ruleName': '',
                        'status': '1',
                        'desc': '',
                        'sectionNo': '',
                        'province': '',
                        'mobilCorp': '',
                    }
                }
            }
            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '说明不能为空');
                    return
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    var val = $(".sectionNo1").val().length;
                    if ((val != 0) && (val < 2 || val > 10)) {
                        App.alert("号段只能输入2到10位数字");
                        $scope.addData.sectionNo = "";
                        return
                    } else if (val == 0) {
                        $scope.addData.sectionNo = "";
                        return
                    }
                    MyFactory.PostAjax('userRouteRule/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    var val = $(".sectionNo1").val().length;
                    if ((val != 0) && (val < 2 || val > 10)) {
                        App.alert("号段只能输入2到10位数字");
                        $scope.addData.sectionNo = "";
                        return
                    } else if (val == 0) {
                        $scope.addData.sectionNo = ""
                        return
                    }
                    MyFactory.PostAjax('userRouteRule/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/userRouteRule/delete', {
                    'ruleId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
        } else {

            location.href = '#/forbid';
        }
    });

});




//========优先级管理==========//
app.controller('priorityManage', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'priorityManage', function (data) {
        if (data.data.isSuccess) {
            //获取优先级管理
            MyFactory.PostAjax('priRuleDef/getAll', {}, function (data) {
                $scope.levelData = data;
            })
            $scope.searchData = {
                ruleId: '',
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/priRuleDef/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/priRuleDef/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('priRuleDef/changeStatus', {
                    'ruleId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };
            //添加或者编辑挂载数据
            $scope.addData = {
                'ruleId': '',
                'level': '',
                'status': '1',
                'desc': '',
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    MyFactory.PostAjax('priRuleDef/toUpdate', {
                        'ruleId': code
                    }, function (data) {

                        $scope.addData.ruleId = data.ruleId;
                        $scope.addData.level = data.level;
                        $scope.addData.status = data.status;
                        $scope.addData.desc = data.desc;
                    })
                } else {
                    $scope.addData = {
                        'ruleId': '',
                        'level': '',
                        'status': '1',
                        'desc': '',
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body input")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                if ($scope.addData.desc == '') {
                    App.promptOne(document.querySelector('#desc'), '优先级管理说明不能为空');
                    return
                }

                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('priRuleDef/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            MyFactory.PostAjax('priRuleDef/getAll', {}, function (data) {
                                $scope.levelData = data;
                            })
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    var level = $(".level").val();
                    if (level < 0) {
                        App.alert("优先级为非负数");
                        return
                    }
                    MyFactory.PostAjax('priRuleDef/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            MyFactory.PostAjax('priRuleDef/getAll', {}, function (data) {
                                $scope.levelData = data;
                            })
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            };
            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/priRuleDef/delete', {
                    'ruleId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg);
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg);
                    }
                })
            };
            //导出表格信息
            $scope.outExcel = function () {
                $('#form').submit();
            };
        } else {

            location.href = '#/forbid';
        }
    });


});

// =========路由通道设置 业务类型========= //
app.controller('routeServiceType', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'routeServiceType', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                serviceCode: '',
                gateLinkId: ''
            };

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/routeGate/queryByServiceCode', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/routeGate/queryByServiceCode', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })
                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //短信类型下拉列表
            MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                $scope.listData1 = data;
            })
            MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                $scope.listData2 = data;
            })
            //通道优先级下拉列表
            $scope.dataUp = function () {
                $scope.setData = [];
                $scope.smsData = [];
                MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                    $scope.listData2 = data;
                    for (var index = 0; index <= data.length; index++) {
                        $scope.setData.push({
                            'GATE_LINK_ID': data[index].GATE_LINK_ID,
                            'GATE_LINK_NAME': data[index].GATE_LINK_NAME,
                            'isSelected': false
                        });
                        $scope.smsData.push({
                            'GATE_LINK_ID': data[index].GATE_LINK_ID,
                            'GATE_LINK_NAME': data[index].GATE_LINK_NAME,
                            'isSelected': false
                        });
                    };
                });
            }
            // 监测第一优先级选项
            $scope.checkboxClick1 = function (event, idx) {
                var checkbox = event.target;
                if (checkbox.checked) {
                    $scope.setData[idx].isSelected = true;
                    for (var i = 0; i <= $scope.smsData.length; i++) {
                        if ($scope.smsData[i].GATE_LINK_ID === checkbox.value) {
                            $scope.smsData[i].isSelected = false;
                            $scope.smsData.splice(i, 1);
                        }
                    }
                } else if (!checkbox.checked) {
                    $scope.setData[idx].isSelected = false;
                    $scope.smsData.push({
                        'GATE_LINK_NAME': checkbox.getAttribute('sName'),
                        'GATE_LINK_ID': checkbox.getAttribute('value'),
                        'isSelected': false
                    });
                }
            }
            // 监测第二优先级选项
            $scope.checkboxClick2 = function (event, idx) {
                var checkbox = event.target;
                if (checkbox.checked) {
                    $scope.smsData[idx].isSelected = true;
                    for (var i = 0; i <= $scope.setData.length; i++) {
                        if ($scope.setData[i].GATE_LINK_ID === checkbox.value) {
                            $scope.setData[i].isSelected = false;
                            $scope.setData.splice(i, 1);
                        }
                    }
                    smsSel.push(checkbox.getAttribute('value'));
                } else if (!checkbox.checked) {
                    $scope.smsData[idx].isSelected = false;
                    $scope.setData.push({
                        'GATE_LINK_NAME': checkbox.getAttribute('sName'),
                        'GATE_LINK_ID': checkbox.getAttribute('value'),
                        'isSelected': false
                    });
                }
            }


            //添加或者编辑挂载数据
            $scope.addData = {
                'serviceCode': '',
                'firstGateIds': '',
                'secondGateIds': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/routeGate/toUpdate', {
                        'serviceCode': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.serviceCode);
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.oldServiceCode = data.serviceCode;
                        var fistGateIds = data.firstGateIds.split(",");
                        var secondGateIds = data.secondGateIds.split(",");
                        $scope.dataUp();
                        $timeout(function () {
                            for (var i = 0; i < $scope.setData.length; i++) {
                                $scope.setData[i].isSelected = false;
                                fistGateIds.forEach(function (v) {
                                    if ($scope.setData[i].GATE_LINK_ID === v) {
                                        $scope.setData[i].isSelected = true;
                                        for (var a = 0; a < $scope.smsData.length; a++) {
                                            if ($scope.smsData[a].GATE_LINK_ID == $scope.setData[i].GATE_LINK_ID) {
                                                $scope.smsData.splice(a, 1);
                                            }
                                        }
                                    }
                                });
                            }
                            for (var j = 0; j < $scope.smsData.length; j++) {
                                $scope.smsData[j].isSelected = false;
                                secondGateIds.forEach(function (v) {
                                    if ($scope.smsData[j].GATE_LINK_ID === v) {
                                        $scope.smsData[j].isSelected = true;
                                        for (var b = 0; b < $scope.setData.length; b++) {
                                            if ($scope.setData[b].GATE_LINK_ID == $scope.smsData[j].GATE_LINK_ID) {
                                                $scope.setData.splice(b, 1);
                                            }
                                        }
                                    }
                                });
                            }
                        }, 1000)
                    });
                } else {
                    $scope.dataUp();
                    $timeout(function () {
                        for (var i = 0; i <= $scope.smsData.length; i++) {
                            $scope.setData[i].isSelected = false;
                            $scope.smsData[i].isSelected = false;
                        }
                    }, 500)
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'serviceCode': '',
                        'firstGateIds': '',
                        'secondGateIds': ''
                    }
                }
            }
            //添加和修改数据
            $scope.editSave = function () {
                var smsSel = [];
                var setSel = [];
                for (var i = 0; i < $scope.smsData.length; i++) {
                    if ($scope.smsData[i].isSelected == true) {
                        smsSel.push($scope.smsData[i].GATE_LINK_ID);
                    }
                }
                for (var j = 0; j < $scope.setData.length; j++) {
                    if ($scope.setData[j].isSelected == true) {
                        setSel.push($scope.setData[j].GATE_LINK_ID);
                    }
                }
                $scope.addData.firstGateIds = setSel.toString();
                $scope.addData.secondGateIds = smsSel.toString();
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('/routeGate/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('/routeGate/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.deleteId = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/routeGate/delete', {
                    'serviceCode': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
        } else {

            location.href = '#/forbid';
        }
    });

});

// =========路由通道设置 通道类型========= //
app.controller('routePassType', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'routePassType', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                serviceCode: '',
                gateLinkId: ''
            };

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/routeGate/queryByGate', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/routeGate/queryByGate', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })
                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            $scope.dataUp = function () {
                $scope.matData = [];
                $scope.mamData = [];
                //业务端下拉列表
                MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                    $scope.listData1 = data;
                    for (var index = 0; index <= data.length; index++) {
                        $scope.matData.push({
                            'serviceCode': data[index].serviceCode,
                            'serviceName': data[index].serviceName,
                            'isSelected': false
                        });
                        $scope.mamData.push({
                            'serviceCode': data[index].serviceCode,
                            'serviceName': data[index].serviceName,
                            'isSelected': false
                        });
                    };

                })
            }
            MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                $scope.listData1 = data;
            })
            //通道优先级下拉列表
            MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                $scope.listData2 = data;
            })

            // 监测第一优先级选项
            $scope.checkboxClick1 = function (event, idx) {
                var checkbox = event.target;
                if (checkbox.checked) {
                    $scope.matData[idx].isSelected = true;
                    for (var i = 0; i <= $scope.mamData.length; i++) {
                        if ($scope.mamData[i].serviceCode === checkbox.value) {
                            $scope.mamData[i].isSelected = false;
                            $scope.mamData.splice(i, 1);
                        }
                    }
                } else if (!checkbox.checked) {
                    $scope.matData[idx].isSelected = false;
                    $scope.mamData.push({
                        'serviceName': checkbox.getAttribute('sName'),
                        'serviceCode': checkbox.getAttribute('value'),
                        'isSelected': false
                    });
                }
            }
            // 监测第二优先级选项
            $scope.checkboxClick2 = function (event, idx) {
                var checkbox = event.target;
                if (checkbox.checked) {
                    $scope.mamData[idx].isSelected = true;
                    for (var i = 0; i <= $scope.matData.length; i++) {
                        if ($scope.matData[i].serviceCode === checkbox.value) {
                            $scope.matData[i].isSelected = false;
                            $scope.matData.splice(i, 1);
                        }
                    }
                } else if (!checkbox.checked) {
                    $scope.mamData[idx].isSelected = false;
                    $scope.matData.push({
                        'serviceName': checkbox.getAttribute('sName'),
                        'serviceCode': checkbox.getAttribute('value'),
                        'isSelected': false
                    });
                }
            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'gateLinkId': '',
                'firstSvrIds': '',
                'secondSvrIds': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/routeGate/toUpdateByGate', {
                        'gateLinkId': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.gateLinkId);
                        $scope.addData.gateLinkId = data.gateLinkId;
                        $scope.addData.oldGateLinkId = data.gateLinkId;
                        var fistServiceCodes = data.firstSvrIds.split(",");
                        var secondServiceCodes = data.secondSvrIds.split(",");
                        $scope.dataUp();
                        $timeout(function () {
                            for (var i = 0; i < $scope.matData.length; i++) {
                                $scope.matData[i].isSelected = false;
                                fistServiceCodes.forEach(function (v) {
                                    if ($scope.matData[i].serviceCode === v) {
                                        $scope.matData[i].isSelected = true;
                                        for (var a = 0; a < $scope.mamData.length; a++) {
                                            if ($scope.mamData[a].serviceCode == $scope.matData[i].serviceCode) {
                                                $scope.mamData.splice(a, 1);
                                            }
                                        }
                                    }
                                });
                            }
                            for (var j = 0; j < $scope.mamData.length; j++) {
                                $scope.mamData[j].isSelected = false;
                                secondServiceCodes.forEach(function (v) {
                                    if ($scope.mamData[j].serviceCode === v) {
                                        $scope.mamData[j].isSelected = true;
                                        for (var b = 0; b < $scope.matData.length; b++) {
                                            if ($scope.matData[b].serviceCode == $scope.mamData[j].serviceCode) {
                                                $scope.matData.splice(b, 1);
                                            }
                                        }
                                    }
                                });
                            }
                        }, 500)
                    })
                } else {
                    $scope.dataUp();
                    $timeout(function () {
                        for (var i = 0; i <= $scope.matData.length; i++) {
                            $scope.matData[i].isSelected = false;
                            $scope.mamData[i].isSelected = false;
                        }
                    }, 500);
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'gateLinkId': '',
                        'firstSvrIds': '',
                        'secondSvrIds': ''
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {
                var mamSel = [];
                var matSel = [];
                for (var i = 0; i < $scope.mamData.length; i++) {
                    if ($scope.mamData[i].isSelected == true) {
                        mamSel.push($scope.mamData[i].serviceCode);
                    }
                }
                for (var j = 0; j < $scope.matData.length; j++) {
                    if ($scope.matData[j].isSelected == true) {
                        matSel.push($scope.matData[j].serviceCode);
                    }
                }
                $scope.addData.firstSvrIds = matSel.toString();
                $scope.addData.secondSvrIds = mamSel.toString();
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('/routeGate/updateByGate', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('/routeGate/saveByGate', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.deleteId = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/routeGate/deleteByGate', {
                    'gateLinkId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
        } else {

            location.href = '#/forbid';
        }
    });

});

// =========虚拟通道设置========= //
app.controller('virtualChannelSetup', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'virtualChannelSetup', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                gateLinkId: '',
                virtualGateLinkId: ''
            };

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/virtualGateLink/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/virtualGateLink/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })
                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //通道选择下拉列表
            MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                $scope.listData2 = data;
            })

            $scope.virData = [];
            //虚拟通道下拉接口列表
            MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                for (var index = 0; index <= data.length; index++) {
                    $scope.virData.push({
                        'GATE_LINK_ID': data[index].GATE_LINK_ID,
                        'GATE_LINK_NAME': data[index].GATE_LINK_NAME,
                        'isSelected': false
                    });
                };

            })

            // 监控勾选虚拟通道
            var virSel = [];
            $scope.checkboxClick = function (event, idx) {
                var checkbox = event.target;
                if (checkbox.checked) {
                    $scope.virData[idx].isSelected = true;
                    virSel.push(checkbox.value);
                } else if (!checkbox.checked) {
                    $scope.virData[idx].isSelected = false;
                    var index = virSel.indexOf(checkbox.value);
                    virSel.splice(index, 1);
                }
            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'gateLinkId': '',
                'virtualGateLinkId': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/virtualGateLink/toUpdate', {
                        'gateLinkId': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.gateLinkId);
                        $scope.addData.gateLinkId = data.gateLinkId;
                        $scope.addData.oldGateLinkId = data.gateLinkId;
                        var virtualGateLinkId = data.virtualGateLinkId.split(",");
                        virSel.splice(0, virSel.length);
                        for (var i = 0; i <= $scope.virData.length; i++) {
                            $scope.virData[i].isSelected = false;
                            virtualGateLinkId.forEach(function (v) {
                                if ($scope.virData[i].GATE_LINK_ID === v) {
                                    $scope.virData[i].isSelected = true;
                                    virSel.push(v);
                                }
                            });
                        }
                    })
                } else if (str == '添加') {
                    $scope.addData.gateLinkId = '';
                    for (var i = 0; i <= $scope.virData.length; i++) {
                        $scope.virData[i].isSelected = false;
                        virSel.splice(0, virSel.length);
                    }
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'gateLinkId': '',
                        'virtualGateLinkId': ''
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {
                if (virSel.length == 0) {
                    for (var i = 0; i < $scope.virData.length; i++) {
                        if ($scope.virData[i].isSelected == true) {
                            virSel.push($scope.virData[i].GATE_LINK_ID);
                        }
                    }
                }
                $scope.addData.virtualGateLinkId = virSel.toString();
                virSel.splice(0, virSel.length);
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('/virtualGateLink/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('/virtualGateLink/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
                $scope.virData.isSelected = false;
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.deleteId = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/virtualGateLink/delete', {
                    'gateLinkId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
        } else {

            location.href = '#/forbid';
        }
    });

});

//========短信优先级分配==========//
app.controller('messagepriorityMent', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'messagepriorityMent', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                ruleId: '',
                svrNode: '',
                serviceCode: '',
                isLevel: '',
            };
            //获取优先级管理
            MyFactory.PostAjax('priRuleDef/getAll', {}, function (data) {
                $scope.levelData = data;
            })
            //业务端下拉列表
            MyFactory.setSms($scope);

            //限制搜索中优先级与是否分配不能同时选择
            $scope.selectRuleId = function () {
                $scope.searchData.isLevel = '';
            }
            $scope.selectIsLevel = function () {
                $scope.searchData.ruleId = '';
            }


            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/priAlloc/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/priAlloc/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })
                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            $scope.editTr = function (code) {
                $scope.addData = {};
                $scope.addData.recId = code;
                MyFactory.PostAjax('priAlloc/toUpdate', {
                    'recId': code
                }, function (data) {
                    MyFactory.getServiceCode($scope, 'serviceList', data.svrNode);
                    $scope.addData.ruleId = data.ruleId;
                    $scope.addData.svrNode = data.svrNode;
                    $scope.addData.serviceCode = data.serviceCode;
                    $scope.addData.desc = data.desc;
                })
            }
            $scope.editSave = function () {

                if ($scope.addData.desc == '') {
                    App.promptOne(App.d('#desc'), '优先级说明不能为空');
                    return
                }
                //信息无误开始请求
                MyFactory.PostAjax('priAlloc/update', $scope.addData, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData();
                        App.alert(data.msg, function () {
                            $('#add').modal('hide');
                        })
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
            $scope.search = function () {
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
        } else {

            location.href = '#/forbid';
        }
    });

});
//========专线互联网切换==========//
app.controller('internetSwitch', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'internetSwitch', function (data) {
        if (data.data.isSuccess) {
            //初始化
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/gateSwtich/query', {}, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    if (callback) {
                        callback()
                    }
                });
            }
            $scope.upData();
            //无id专线互联网切换
            $scope.switchData1 = {
                'status': '',
                'pwd': ''
            };
            $scope.allChange = function () {
                // if ($scope.switchData.status == "1") {
                //     $scope.switchData.status = "2"
                // } else {
                //     $scope.switchData.status = "1"
                // }
                MyFactory.PostAjax('/gateSwtich/autoChangeLine', {
                    'status': $scope.switchData1.status,
                    'pwd': hex_md5($scope.switchData1.pwd)
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg);
                    } else if (data.isSuccess == true) {
                        $scope.upData();
                        App.alert(data.msg, function () {
                            $('#add2').modal('hide');
                        });
                    }
                })
            };

            $scope.switchData = {
                'pwd': ''
            }


            //有id切换
            $scope.switchA = function (value, id) {

                $scope.startAll = function () {
                    if ($scope.switchData.pwd == '') {
                        App.alert('密码不能为空');
                        return
                    }
                    if (value == "2") {
                        MyFactory.PostAjax('gateSwtich/changeLineType', {
                            'lineType': '2',
                            'pwd': hex_md5($scope.switchData.pwd),
                            'recId': id
                        }, function (data) {
                            if (data.isSuccess == false) {
                                App.alert(data.msg)
                            } else if (data.isSuccess == true) {
                                $scope.upData();
                                App.alert(data.msg, function () {
                                    $scope.switchData.pwd = '';
                                    $('#add').modal('hide');
                                });
                            }
                        })
                    }
                    if (value == "1") {
                        MyFactory.PostAjax('gateSwtich/changeLineType', {
                            'lineType': '1',
                            'pwd': hex_md5($scope.switchData.pwd),
                            'recId': id
                        }, function (data) {
                            if (data.isSuccess == false) {
                                App.alert(data.msg)
                            } else if (data.isSuccess == true) {
                                $scope.upData();
                                App.alert(data.msg, function () {
                                    $scope.switchData.pwd = '';
                                    $('#add').modal('hide');
                                });
                            }
                        })
                    }

                }
            }
        } else {

            location.href = '#/forbid';
        }
    });

})


//========= 短信系统一键切换 ===========//
app.controller('smsSystemOnekeySwitch', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsSystemOnekeySwitch', function (data) {
        if (data.data.isSuccess) {
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/netSwtich/queryIdOrName', {}, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    if (callback) {
                        callback()
                    }
                });
            }
            $scope.upData();

            $scope.search = function () {
                $scope.upData();
            }
            // 新旧短信平台切换
            $scope.addData = {
                'pwd': ''
            };
            $scope.switch = function (value, id) {
                $scope.changeAll = function () {
                    if ($scope.addData.pwd == '') {
                        App.alert('请输入密码');
                        return
                    }
                    MyFactory.PostAjax('/netSwtich/changeTerrace', {
                        'lineType': $scope.switchAll,
                        'pwd': hex_md5($scope.addData.pwd)
                    }, function (data) {
                        if (data.isSuccess == false) {
                            $scope.addData.pwd = '';
                            App.alert(data.msg);
                        } else if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $scope.addData.pwd = '';
                                $('#add1').modal('hide');
                            });
                        }
                    })
                }
            }
        } else {

            location.href = '#/forbid';
        }
    });

})




//========统一监控大图==========//
app.controller('unifyMonitor', function ($scope, MyFactory, $interval) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'unifyMonitor', function (data) {
        if (data.data.isSuccess) {
            //全屏显示
            var winW = window.screen.availWidth;
            var oDiv = document.querySelector('.bigScreen');
            oDiv.style.width = winW + 'px';
            oDiv.style.position = 'fixed';
            oDiv.style.left = 0;
            oDiv.style.top = 0;
            oDiv.style.zIndex = 2000;

            //获取当前时间n分钟后的时间函数
            function addMinutes(date, minutes) {
                minutes = parseInt(minutes);
                var interTimes = minutes * 60 * 1000;
                interTimes = parseInt(interTimes);
                var dateTime = new Date(Date.parse(date) + interTimes);
                var hour = dateTime.getHours();
                var min = dateTime.getMinutes();
                if (min < 10) {
                    min = '0' + min
                }
                return hour + ":" + min;
            }
            //时间格式转化为时间戳
            function timeChangetype(stringTime) {
                var timestamp2 = Date.parse(new Date(stringTime));
                return timestamp2;
            }

            var date = new Date();

            //获取图表的x轴
            var datax = [];
            for (var i = 0; i <= 144; i++) {
                datax.push(addMinutes(date, i * (-10)));
            }
            datax[0] = '(今天)' + datax[0];
            datax[datax.length - 1] = datax[datax.length - 1] + '(昨天)';
            var year = date.getFullYear(); //获取完整的年份(4位,1970-????)
            var month = date.getMonth() + 1; //获取当前月份(0-11,0代表1月)
            var nowDate = date.getDate(); //获取当前日(1-31)
            var hour = date.getHours(); //获取当前小时数
            var minutes = date.getMinutes(); //获取当前分钟数(0-59)
            var nowtime = year + '/' + month + '/' + nowDate + ' ' + hour + ':' + minutes + ':00'; //獲取當前時間整分鐘
            var endTime = new Date(nowtime).getTime(); //当前分钟的时间戳 单位：毫秒
            var startTime = endTime - 86400000; //24小时前的时间戳
            var startDate = timeChangetype(startTime); //把时间转换为为时间戳
            var endDate = timeChangetype(endTime);

            $scope.todayDate = year + '-' + month + '-' + nowDate;
            $scope.searchData = {
                'startDate': startDate / 1000, //時間戳單位為秒 开始时间秒数以00结尾
                'endDate': endDate / 1000, //结束时间以秒数59结尾
                'interval': 600 //單位為秒
            }

            //点击选择显示的网关通道
            $scope.selectShow = false;
            $scope.selectS = '0';
            $scope.select = function () {
                if ($scope.selectShow == false) {
                    $scope.selectShow = true;
                    $scope.selectS = 1
                    //显示的网关通道
                    MyFactory.PostAjax('gateDef/getGateLink', '', function (data) {
                        $scope.selectData = [];
                        for (var i = 0; i < data.length; i++) {
                            $scope.selectData.push({
                                'gateLinkName': data[i].GATE_LINK_NAME,
                                'gateLinkId': data[i].GATE_LINK_ID,
                                'isSelected': false
                            })
                        };
                        //初始化点击设置的弹框选项
                        $("#gateLink").html('');
                        for (var i = 0; i < $scope.selectData.length; i++) {
                            $("#gateLink").append("<span style='display: inline-block;min-width: 25%;margin-right: 4%;'><input type='checkbox' value='" + $scope.selectData[i].gateLinkId + "'name='gateLinkItem'/>" + "<span style='position: relative;bottom: 3px;'>&nbsp;" + $scope.selectData[i].gateLinkName + "</span></span>");
                        };
                    });
                    var obj = document.getElementsByName('gateLinkItem');
                    for (var j = 0; j < obj.length; j++) { //默认为不勾选
                        $(obj[j]).prop("checked", false);
                    }
                    MyFactory.PostAjax('userGate/find', '', function (data) {
                        if (data.length > 0) {
                            for (var i = 0; i < data.length; i++) {
                                for (var j = 0; j < $scope.selectData.length; j++) {
                                    if ($scope.selectData[j].gateLinkId == data[i].gateLinkId) {
                                        $(':input[value=' + $scope.selectData[j].gateLinkId + ']').prop("checked", true);
                                    }
                                }
                            }
                        } else {
                            for (var i = 0; i < 4; i++) {
                                for (var j = 0; j < $scope.selectData.length; j++) {
                                    if ($scope.selectData[j].gateLinkId == data[i].gateLinkId) {
                                        $(':input[value=' + $scope.selectData[j].gateLinkId + ']').prop("checked", true);
                                    }
                                }
                            }
                        }

                    });
                } else {

                    $scope.selectShow = false;
                    $scope.selectS = '0';
                }
            }
            //显示的网关通道的保存
            $scope.gateSave = function (value) {
                var list = $("#gateLink input");

                var arr1 = [];
                for (var i = 0; i < list.length; i++) {
                    if ($(list[i]).prop('checked') == true) {
                        arr1.push($(list[i]).val());
                    }
                };
                var str = arr1.join(',');
                MyFactory.PostAjax('userGate/update', {
                    'gateLinkIds': str
                }, function (data) {

                    if (data.isSuccess == true) {
                        $scope.selectShow = false; //隐藏选择框
                        $scope.selectS = '0';
                        //网关接口发送速率接口
                        MyFactory.PostAjax('unifyMon/findGateSpeed', {
                            'gateLinkIds': str
                        }, function (data) {
                            //	             		      $scope.findGateData=[{'itemName':11},{'itemName':117}];
                            $scope.findGateData = data;
                            $scope.findGateId = [];
                            //仪表图
                            //捕获 渲染完成事件
                            $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
                                var maxFlow, units;
                                angular.forEach($scope.findGateData, function (item, key) {
                                    var time = 'time' + key;
                                    if (item.units == 1) { //指值的值为万
                                        units = '万条';
                                        maxFlow = item.maxFlow / 10000;
                                    } else {
                                        units = '条';
                                        maxFlow = item.maxFlow
                                    }
                                    MyFactory.meterChart('unifyMon/findGateSpeed', item.itemName, item.gateLinkName, item.valueInt, maxFlow, $scope, time, $scope.str, units);
                                })


                            });
                        })
                        App.alert(data.msg, function () { });
                    } else {
                        App.alert(data.msg);
                    }
                });
            }

            //业务系统接口
            //传输速率
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_cur_flow'
            }, function (data) {
                $scope.curData = data;
                $scope.curvalue = 10000;
            })
            //已发送量
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_send_num'
            }, function (data) {
                $scope.sendData = data;
                $scope.sendvalue = 50000000;

            })
            //平均速率
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_avg_flow'
            }, function (data) {
                $scope.avgData = data;
                $scope.avgvalue = 10000;
            })
            //峰值速率
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_max_flow'
            }, function (data) {
                $scope.maxData = data;
                $scope.maxvalue = 10000;
            })


            //警告信息接口
            var warm = function (callback) {

                MyFactory.PostAjax('unifyMon/findWarn', '', function (data) {
                    $scope.warnMessageData = data;
                    //捕获 渲染完成事件
                    if (callback) {
                        callback();
                    }


                })

            }
            warm(function () {
                //   		alert('开始');
                $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
                    if (ul1.scrollHeight <= 80) {
                        return;
                    } else {
                        window.onload = roll();

                        function roll() {
                            var ul1 = document.getElementById("ul1");
                            var ul2 = document.getElementById("ul2");
                            var box = document.getElementById("box");
                            ul2.innerHTML = ul1.innerHTML;
                            box.scrollTop = 0;
                            $scope.timerGun = $interval(rollStart, 50);

                            box.onmouseover = function () {
                                $interval.cancel($scope.timerGun)

                            }
                            box.onmouseout = function () {
                                $scope.timerGun = $interval(rollStart, 50);
                            }
                        }

                        function rollStart() {
                            if (box.scrollTop >= ul1.scrollHeight) { //scrollTop属性既是scroll最上端和box的距离
                                box.scrollTop = 0;
                            } else {
                                box.scrollTop++;
                            }

                        }
                    }
                });

            });
            //服务器状态接口
            //服务器状况
            MyFactory.PostAjax('unifyMon/findService', {
                'objType': 'host',
                'itemNames': 'recuse, hardware',
                'keys': 'cpu, memuse, recv, send'
            }, function (data) { //hdiskname,diskuse,
                $scope.servesData = data;
            })
            //redis监控
            MyFactory.PostAjax('unifyMon/findService', {
                'objType': 'redis',
                'itemNames': 'basic',
                'keys': 'memuse, savestatus, links'
            }, function (data) {
                $scope.redisData = data;
            })
            //oracle状态
            MyFactory.PostAjax('unifyMon/findService', {
                'objType': 'rac',
                'itemNames': 'racinfo',
                'keys': 'state'
            }, function (data) {
                $scope.racData = data;
            })
            //tomcat
            MyFactory.PostAjax('unifyMon/findService', {
                'objType': 'tomcat',
                'itemNames': 'info',
                'keys': 'mem, reqs, threads, reqmaxtime, esptime, reqsuc, reqfail'
            }, function (data) {
                $scope.tomcatData = data;
            })

            //短信平台缓存数据接口
            MyFactory.PostAjax('unifyMon/findQueue', $scope.searchData, function (data) {
                $scope.cachelenData = [];
                $scope.pri = [];
                var findQueueData = data;
                var cachelen = findQueueData.cachelen; //表示缓存队列
                var pri = findQueueData.pri; //表示优先级队列
                angular.forEach(cachelen, function (item) {
                    $scope.cachelenData.push(item.value);
                })
                angular.forEach(pri, function (item) {
                    if (item.units == 1) {
                        $scope.unit3 = '缓存数据(万条)';
                    } else {
                        $scope.unit3 = '缓存数据(条)';
                    }
                    $scope.pri.push(item.value);
                })
                MyFactory.realTimeFn2('unifyMon/findQueue', datax, 'cache', '短信平台队列监控', '待处理队列', '待发送队列', $scope.unit3, ['#0a559c', '#112f3a'], ['#000', '#fff'], $scope.cachelenData, $scope.pri, $scope);
            })

            //短信平台实时速率接口 .value
            MyFactory.PostAjax('unifyMon/findCurFlow', $scope.searchData, function (data) {
                $scope.findCurData = [];
                var findCur = data;
                angular.forEach(findCur, function (item) {
                    if (item.units = 1) {
                        $scope.unit2 = '实时速率(万条/分)';
                    } else {
                        $scope.unit2 = '实时速率(条/分)';
                    }
                    $scope.findCurData.push(item.value);

                })
                MyFactory.realTimeFn1('unifyMon/findCurFlow', datax, 'realTime', '短信平台实时速率', '实时速率', $scope.unit2, ['#048a59', '#0f2b33'], $scope.findCurData, $scope);
            })

            //获取显示的通道
            MyFactory.PostAjax('userGate/find', '', function (data) {

                $scope.str = [];
                var selected = [];
                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        selected.push(data[i].gateLinkId);
                    }
                }
                $scope.str = selected.join(',');
                //网关接口发送速率接口
                MyFactory.PostAjax('unifyMon/findGateSpeed', '', function (data) {
                    $scope.findGateData = data;
                    if ($scope.findGateData == '' || $scope.findGateData == '[]') {
                        $scope.findGateData = [{
                            'a': 11
                        }];
                    }
                    $scope.findGateId = [];
                    //仪表图
                    //捕获 渲染完成事件
                    $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
                        var maxFlow, units;
                        $scope.timers = [];
                        angular.forEach($scope.findGateData, function (item, key) {
                            $scope.timers.push(key);
                            var time = 'time' + key; //用来定义定时器
                            if (item.units == 1) { //指值的值为万
                                units = '万条';
                                maxFlow = item.maxFlow / 10000;
                            } else {
                                units = '条';
                                maxFlow = item.maxFlow
                            }
                            MyFactory.meterChart('unifyMon/findGateSpeed', item.itemName, item.gateLinkName, item.valueInt, maxFlow, $scope, time, $scope.str, units);
                        })
                    });
                })
            });


            //短信平台实时数据接口
            MyFactory.PostAjax('unifyMon/findSmSend', '', function (data) {
                $scope.findSmSendData = [];
                var findSmSend = data;
                var units;
                angular.forEach(findSmSend, function (item) {
                    var obj = {};
                    obj.value = item.valueInt;
                    obj.name = item.keyCn;
                    $scope.findSmSendData.push(obj);
                    if (item.units == 1) { //指值的值为万
                        units = '短信平台实时数据(万条)';
                    } else {
                        units = '短信平台实时数据(条)';
                    }
                })
                //饼图
                MyFactory.unifycircle('realTimeCircle', units, ['#ffc600', '#ff6000', '#ccc'], $scope.findSmSendData);
            })
            //各通道短信发送比接口
            MyFactory.PostAjax('unifyMon/findGateSmSend', '', function (data) {
                $scope.findGateSmSendData = [];
                var findGateSmSend = data;
                var units;
                angular.forEach(findGateSmSend, function (item) {
                    var obj = {};
                    obj.value = item.value;
                    obj.name = item.gateLinkName;
                    $scope.findGateSmSendData.push(obj);
                    if (item.units == 1) { //指值的值为万
                        units = '各通道短信发送比(万条)';
                    } else {
                        units = '各通道短信发送比(条)';
                    }
                })
                MyFactory.unifycircle('SMSsend', units, ['#7ecc21', '#ffc600', '#ff6000', '#ccc'], $scope.findGateSmSendData);
            })
            //滚动
            MyFactory.unifySlide($scope, '.JGslide', 'p', 'JGup', 'JGdown')


            //业务切换tab
            $scope.YWtabNum = 4;
            $scope.show = 4;
            //平均速率
            $scope.average = function () {
                $scope.YWtabNum = 1;
                $scope.show = 1
            }
            //已发送量
            $scope.send = function () {
                $scope.YWtabNum = 2;
                $scope.show = 2
            }
            //峰值速率
            $scope.peak = function () {
                $scope.YWtabNum = 3;
                $scope.show = 3
            }
            //传输速率
            $scope.transmission = function () {
                $scope.YWtabNum = 4;
                $scope.show = 4
            }

            //FWQ切换tab
            $scope.FWQtabNum = 1;
            $scope.serverShow = 1;
            //服务器状态
            $scope.servers = function () {
                $scope.FWQtabNum = 1;
                $scope.serverShow = 1
            }
            //redius监控
            $scope.redius = function () {
                $scope.FWQtabNum = 2;
                $scope.serverShow = 2
            }
            //oracle监控
            $scope.oracle = function () {
                $scope.FWQtabNum = 3;
                $scope.serverShow = 3
            }
            //tomcat监控
            $scope.tomcat = function () {
                $scope.FWQtabNum = 4;
                $scope.serverShow = 4
            }
            //离开页面的时候 清除定时器

            $scope.$on('$destroy', function () {
                if ($scope.timer) {
                    $interval.cancel($scope.timer);
                    $scope.timer = null;
                }
                if ($scope.timer1) {
                    $interval.cancel($scope.timer1);
                    $scope.timer1 = null;
                }
                for (var i = 0; i < $scope.timers.length; i++) {
                    if ($scope['time' + i]) {
                        $interval.cancel($scope['time' + i]);
                        $scope['time' + i] = null;
                    }
                }
                if ($scope.timerGun) {
                    $interval.cancel($scope.timerGun);
                    $scope.timerGun = null;
                }
            });
        } else {

            location.href = '#/forbid';
        }
    });
})


//========统一监控小图==========//
app.controller('smunifyMonitor', function ($scope, MyFactory, $interval) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smunifyMonitor', function (data) {
        if (data.data.isSuccess) {
            //获取当前时间n分钟后的时间函数
            function addMinutes(date, minutes) {
                minutes = parseInt(minutes);
                var interTimes = minutes * 60 * 1000;
                interTimes = parseInt(interTimes);
                var dateTime = new Date(Date.parse(date) + interTimes);
                var hour = dateTime.getHours();
                var min = dateTime.getMinutes();
                if (min < 10) {
                    min = '0' + min
                }
                return hour + ":" + min;
            }
            //时间格式转化为时间戳
            function timeChangetype(stringTime) {
                var timestamp2 = Date.parse(new Date(stringTime));
                return timestamp2;
            }

            var date = new Date();
            //获取图表的x轴
            var datax = [];
            for (var i = 0; i <= 144; i++) {
                datax.push(addMinutes(date, i * (-10)));
            }
            datax[0] = '(今天)' + datax[0];
            datax[datax.length - 1] = datax[datax.length - 1] + '(昨天)';

            var year = date.getFullYear(); //获取完整的年份(4位,1970-????)
            var month = date.getMonth() + 1; //获取当前月份(0-11,0代表1月)
            var nowDate = date.getDate(); //获取当前日(1-31)
            var hour = date.getHours(); //获取当前小时数
            var minutes = date.getMinutes(); //获取当前分钟数(0-59)
            var nowtime = year + '/' + month + '/' + nowDate + ' ' + hour + ':' + minutes + ':00'; //獲取當前時間整分鐘
            var endTime = new Date(nowtime).getTime(); //当前分钟的时间戳 单位：毫秒
            var startTime = endTime - 86400000; //24小时前的时间戳
            var startDate = timeChangetype(startTime); //把时间转换为为时间戳
            var endDate = timeChangetype(endTime);

            $scope.todayDate = year + '-' + month + '-' + nowDate;
            $scope.searchData = {
                'startDate': startDate / 1000, //時間戳單位為秒 开始时间秒数以00结尾
                'endDate': endDate / 1000, //结束时间以秒数59结尾
                'interval': 600 //單位為秒
            }

            //点击选择显示的网关通道
            $scope.selectShow = false;
            $scope.selectS = '0';
            $scope.select = function () {
                if ($scope.selectShow == false) {
                    $scope.selectShow = true;
                    $scope.selectS = 1
                    //显示的网关通道
                    MyFactory.PostAjax('gateDef/getGateLink', '', function (data) {
                        $scope.selectData = [];
                        for (var i = 0; i < data.length; i++) {
                            $scope.selectData.push({
                                'gateLinkName': data[i].GATE_LINK_NAME,
                                'gateLinkId': data[i].GATE_LINK_ID,
                                'isSelected': false
                            })
                        };
                        //初始化点击设置的弹框选项
                        $("#gateLink").html('');
                        for (var i = 0; i < $scope.selectData.length; i++) {
                            $("#gateLink").append("<span style='display: inline-block;min-width: 25%;margin-right: 4%;'><input type='checkbox' value='" + $scope.selectData[i].gateLinkId + "'name='gateLinkItem'/>" + "<span style='position: relative;bottom: 3px;'>&nbsp;" + $scope.selectData[i].gateLinkName + "</span></span>");
                        };
                    });
                    var obj = document.getElementsByName('gateLinkItem');
                    for (var j = 0; j < obj.length; j++) { //默认为不勾选
                        $(obj[j]).prop("checked", false);
                    }
                    MyFactory.PostAjax('userGate/find', '', function (data) {
                        if (data.length > 0) {
                            for (var i = 0; i < data.length; i++) {
                                for (var j = 0; j < $scope.selectData.length; j++) {
                                    if ($scope.selectData[j].gateLinkId == data[i].gateLinkId) {
                                        $(':input[value=' + $scope.selectData[j].gateLinkId + ']').prop("checked", true);
                                    }
                                }
                            }
                        } else {
                            for (var i = 0; i < 4; i++) {
                                for (var j = 0; j < $scope.selectData.length; j++) {
                                    if ($scope.selectData[j].gateLinkId == data[i].gateLinkId) {
                                        $(':input[value=' + $scope.selectData[j].gateLinkId + ']').prop("checked", true);
                                    }
                                }
                            }
                        }

                    });
                } else {

                    $scope.selectShow = false;
                    $scope.selectS = '0';
                }
            }
            //显示的网关通道的保存
            $scope.gateSave = function (value) {
                var list = $("#gateLink input");

                var arr1 = [];
                for (var i = 0; i < list.length; i++) {
                    if ($(list[i]).prop('checked') == true) {
                        arr1.push($(list[i]).val());
                    }
                };
                var str = arr1.join(',');
                MyFactory.PostAjax('userGate/update', {
                    'gateLinkIds': str
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.selectShow = false; //隐藏选择框
                        $scope.selectS = '0';
                        //网关接口发送速率接口
                        MyFactory.PostAjax('unifyMon/findGateSpeed', {
                            'gateLinkIds': str
                        }, function (data) {
                            //            		      $scope.findGateData=[{'itemName':11},{'itemName':117}];
                            $scope.findGateData = data;
                            $scope.findGateId = [];
                            //仪表图
                            //捕获 渲染完成事件
                            $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
                                var maxFlow, units;
                                angular.forEach($scope.findGateData, function (item, key) {
                                    var time = 'time' + key;
                                    if (item.units == 1) { //指值的值为万
                                        units = '万条';
                                        maxFlow = item.maxFlow / 10000;
                                    } else {
                                        units = '条';
                                        maxFlow = item.maxFlow
                                    }
                                    MyFactory.meterChart('unifyMon/findGateSpeed', item.itemName, item.gateLinkName, item.valueInt, maxFlow, $scope, time, $scope.str, units);
                                })
                            });
                        })
                        App.alert(data.msg, function () { });
                    } else {
                        App.alert(data.msg);
                    }
                });
            }


            //业务系统接口
            //传输速率
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_cur_flow'
            }, function (data) {
                $scope.curData = data;
                $scope.curvalue = 10000;
            })
            //已发送量
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_send_num'
            }, function (data) {
                $scope.sendData = data;
                $scope.sendvalue = 50000000;
            })
            //平均速率
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_avg_flow'
            }, function (data) {
                $scope.avgData = data;
                $scope.avgvalue = 10000;
            })
            //峰值速率
            MyFactory.PostAjax('unifyMon/findSrv', {
                'key': 'srv_max_flow'
            }, function (data) {
                $scope.maxData = data;
                $scope.maxvalue = 10000;
            })


            //警告信息接口
            var warm = function (callback) {
                MyFactory.PostAjax('unifyMon/findWarn', '', function (data) {
                    $scope.warnMessageData = data;
                })
                if (callback) {
                    callback()
                }
            }
            warm(function () {
                $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
                    if (ul1.scrollHeight <= 80) {
                        return;
                    } else {
                        window.onload = roll();

                        function roll() {
                            var ul1 = document.getElementById("ul1");
                            var ul2 = document.getElementById("ul2");
                            var box = document.getElementById("box");

                            ul2.innerHTML = ul1.innerHTML;
                            box.scrollTop = 0;
                            $scope.timerGun = $interval(rollStart, 50);
                            box.onmouseover = function () {
                                $interval.cancel($scope.timerGun)
                            }
                            box.onmouseout = function () {
                                $scope.timerGun = $interval(rollStart, 50);
                            }
                        }

                        function rollStart() {
                            if (box.scrollTop >= ul1.scrollHeight) { //scrollTop属性既是scroll最上端和box的距离
                                box.scrollTop = 0;
                            } else {
                                box.scrollTop++;
                            }

                        }
                    }
                })
            });

            //服务器状态接口
            //服务器状况
            MyFactory.PostAjax('unifyMon/findService', {
                'objType': 'host',
                'itemNames': 'recuse,hardware',
                'keys': 'cpu,memuse,recv,send'
            }, function (data) { //hdiskname,diskuse,
                $scope.servesData = data;
            })
            //redis监控
            MyFactory.PostAjax('unifyMon/findService', {
                'objType': 'redis',
                'itemNames': 'basic',
                'keys': 'memuse,savestatus,links'
            }, function (data) {
                $scope.redisData = data;
            })
            MyFactory.PostAjax('unifyMon/findService', {
                'objType': 'tomcat',
                'itemNames': 'info',
                'keys': 'mem,reqs,threads,reqmaxtime,esptime,reqfail,memrat'
            }, function (data) {
                $scope.tomcatData = data;
            })


            MyFactory.PostAjax('unifyMon/findQueue', $scope.searchData, function (data) {
                $scope.cachelenData = [];
                $scope.pri = [];
                var findQueueData = data;
                var cachelen = findQueueData.cachelen; //表示缓存队列
                var pri = findQueueData.pri; //表示优先级队列
                angular.forEach(cachelen, function (item) {
                    $scope.cachelenData.push(item.value);
                })
                angular.forEach(pri, function (item) {
                    if (item.units == 1) {
                        $scope.unit4 = '缓存数据(万条)';
                    } else {
                        $scope.unit4 = '缓存数据(条)';
                    }
                    $scope.pri.push(item.value);
                })
                MyFactory.realTimeFn2('unifyMon/findQueue', datax, 'cache', '短信平台队列监控', '待处理队列', '待发送队列', $scope.unit4, ['#0a559c', '#112f3a'], ['#000', '#fff'], $scope.cachelenData, $scope.pri, $scope);
            })

            MyFactory.PostAjax('unifyMon/findCurFlow', $scope.searchData, function (data) {
                $scope.findCurData = [];
                var findCur = data;
                angular.forEach(findCur, function (item) {
                    if (item.units == 1) {
                        $scope.unit1 = '实时速率(万条/分)';
                    } else {
                        $scope.unit1 = '实时速率(条/分)';
                    }
                    $scope.findCurData.push(item.value);

                })
                MyFactory.realTimeFn1('unifyMon/findCurFlow', datax, 'realTime', '短信平台实时速率', '实时速率', $scope.unit1, ['#048a59', '#0f2b33'], $scope.findCurData, $scope);
            })
            //    }





            MyFactory.PostAjax('userGate/find', '', function (data) {
                var selected = [];
                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        selected.push(data[i].gateLinkId);
                    }
                }
                $scope.str = selected.join(',');
                //网关接口发送速率接口
                MyFactory.PostAjax('unifyMon/findGateSpeed', {
                    'gateLinkIds': $scope.str
                }, function (data) {
                    //    		      $scope.findGateData=[{'itemName':11},{'itemName':117},{'itemName':110},{'itemName':12},{'itemName':114},{'itemName':109},{'itemName':181},{'itemName':127},{'itemName':130}];
                    $scope.findGateData = data;
                    $scope.findGateId = [];
                    if ($scope.findGateData == '' || $scope.findGateData == '[]') {
                        $scope.findGateData = [{
                            'a': 11
                        }];
                    }
                    //仪表图
                    //捕获 渲染完成事件
                    $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
                        var maxFlow, units;
                        $scope.timers = [];
                        // console.log(data.length);
                        if (data.length !== 0) {
                            angular.forEach($scope.findGateData, function (item, key) {
                                $scope.timers.push(key);
                                var time = 'time' + key;
                                if (item.units == 1) { //指值的值为万
                                    units = '万条';
                                    maxFlow = item.maxFlow / 10000;
                                } else {
                                    units = '条';
                                    maxFlow = item.maxFlow
                                }
                                MyFactory.meterChart('unifyMon/findGateSpeed', item.itemName, item.gateLinkName, item.valueInt, maxFlow, $scope, time, $scope.str, units);

                            })
                        }
                    });
                })
            });

            //短信平台实时数据接口
            MyFactory.PostAjax('unifyMon/findSmSend', '', function (data) {
                $scope.findSmSendData = [];
                var findSmSend = data;
                var units;
                angular.forEach(findSmSend, function (item) {
                    var obj = {};
                    obj.value = item.valueInt;
                    obj.name = item.keyCn;
                    $scope.findSmSendData.push(obj);
                    if (item.units == 1) { //指值的值为万
                        units = '短信平台实时数据(万条)';
                        maxFlow = item.maxFlow / 10000;
                    } else {
                        units = '短信平台实时数据(条)';
                    }
                })
                //饼图
                MyFactory.unifycircle('realTimeCircle', units, ['#ffc600', '#ff6000', '#ccc'], $scope.findSmSendData);
            })
            //各通道短信发送比接口
            MyFactory.PostAjax('unifyMon/findGateSmSend', '', function (data) {
                $scope.findGateSmSendData = [];
                var findGateSmSend = data;
                var units;
                angular.forEach(findGateSmSend, function (item) {
                    var obj = {};
                    obj.value = item.value;
                    obj.name = item.gateLinkName;
                    $scope.findGateSmSendData.push(obj);
                    if (item.units == 1) { //指值的值为万
                        units = '各通道短信发送比(万条)';
                        maxFlow = item.maxFlow / 10000;
                    } else {
                        units = '各通道短信发送比(条)';
                    }
                })
                MyFactory.unifycircle('SMSsend', units, ['#7ecc21', '#ffc600', '#ff6000', '#ccc'], $scope.findGateSmSendData);
            })





            //业务切换tab
            $scope.YWtabNum = 4;
            $scope.show = 4;
            //平均速率
            $scope.average = function () {
                $scope.YWtabNum = 1;
                $scope.show = 1
            }
            //已发送量
            $scope.send = function () {
                $scope.YWtabNum = 2;
                $scope.show = 2
            }
            //峰值速率
            $scope.peak = function () {
                $scope.YWtabNum = 3;
                $scope.show = 3
            }
            //传输速率
            $scope.transmission = function () {
                $scope.YWtabNum = 4;
                $scope.show = 4
            }

            //FWQ切换tab
            $scope.FWQtabNum = 1;
            $scope.serverShow = 1;
            //服务器状态
            $scope.servers = function () {
                $scope.FWQtabNum = 1;
                $scope.serverShow = 1
            }
            //redius监控
            $scope.redius = function () {
                $scope.FWQtabNum = 2;
                $scope.serverShow = 2
            }
            //oracle监控
            $scope.oracle = function () {
                $scope.FWQtabNum = 3;
                $scope.serverShow = 3
            }
            //tomcat监控
            $scope.tomcat = function () {
                $scope.FWQtabNum = 4;
                $scope.serverShow = 4
            }

            $scope.$on('$destroy', function () {
                if ($scope.timer) { //图1定时器

                    $interval.cancel($scope.timer);
                    $scope.timer = null;
                }
                if ($scope.timer1) { //图2定时器

                    $interval.cancel($scope.timer1);
                    $scope.timer1 = null;
                }

                for (var i = 0; i < $scope.timers.length; i++) { //仪表图定时器
                    if ($scope['time' + i]) {
                        $interval.cancel($scope['time' + i]);
                        $scope['time' + i] = null;
                    }
                }
                if ($scope.timerGun) {
                    $interval.cancel($scope.timerGun);
                    $scope.timerGun = null;
                }
            });
        } else {

            location.href = '#/forbid';
        }
    });
})


//========主机总监控==========//
app.controller('hostMonitor', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'hostMonitor', function (data) {
        if (data.data.isSuccess) {
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            $scope.searchData = {
                startDate: '',
                endDate: '',
                objName: ''
            };


            //初始化时间，默认显示当天时间
            MyFactory.Date($scope, '#hostDate', 'startDate', 'endDate');


            //显示事件信息
            $scope.showMethod = function (id, num) {
                MyFactory.PostAjax('mainmon/showExe', {
                    'hostId': id
                }, function (data) {
                    if (num == 1) {
                        $scope.showData = data.data.nowEvent;
                    } else {
                        $scope.showData = data.data.allEvent;
                    }

                })
            }

            //初始化数据
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('hostTotalMon/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'hostTotalMon/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();

            //页数和条数
            MyFactory.selectPage($scope);

            //查询
            $scope.search = function () {
                var str = $('#hostDate').val()
                $scope.searchData.startDate = str.substr(0, 10);
                $scope.searchData.endDate = str.substr(12);
                $scope.searchData.PageNo = 1;
                $scope.upData();
            }




            //修改和添加数据
            $scope.addData = {};
            $scope.alarmusers = [{
                recId: '',
                receiveUser: ''
            }];
            $scope.indexnames = [{
                itemId: '',
                keyNameCn: ''
            }];

            //修改和添加
            $scope.editTr = function (popup, id, mainIp, purpose) {
                $scope.popup = popup;
                if (popup == '修改') {
                    $scope.addstyle = {
                        'display': 'none'
                    };
                    $scope.isDisabled = true;
                    //获取预警接收人下拉
                    MyFactory.PostAjax('mainmon/showIndex', {
                        'hostId': id
                    }, function (data) {
                        $scope.alarmusers = data.data.alarmusers;
                    })
                    //获取修改数据
                    MyFactory.PostAjax('mainmon/updataIndex', {
                        'hostId': id
                    }, function (data) {
                        $scope.indexnames = data.data.index;
                        for (var i = 0; i < data.data.index.length; i++) {
                            $scope.indexnames[i].keyNameCn = data.data.index[i].indexName;
                        }
                        $scope.addData.index = data.data.index;
                        $scope.addData.alarmRecUser = data.data.receiver
                        //将0,1转成布尔值

                        for (var i = 0; i < data.data.receiver.length; i++) {
                            data.data.receiver[i].recAlarmLevel1 = MyFactory.bool(data.data.receiver[i].recAlarmLevel1);
                            data.data.receiver[i].recAlarmLevel2 = MyFactory.bool(data.data.receiver[i].recAlarmLevel2);
                            data.data.receiver[i].recAlarmLevel3 = MyFactory.bool(data.data.receiver[i].recAlarmLevel3);
                        }

                        $scope.addData.hostId = id;
                        $scope.addData.mainIp = mainIp;
                        $scope.addData.remark = purpose;

                    })
                } else {
                    $scope.addData.index = [];
                    $scope.addstyle = {
                        'display': 'block'
                    };
                    $scope.isDisabled = false;
                    $scope.upDataList();
                }
            };

            //选择主机指标名称
            $scope.changeName = function () {
                $scope.upDataList();
            }


            //保存修改和编辑
            $scope.saveTr = function () {
                //接收预警信息
                if ($scope.popup == '修改') {
                    MyFactory.alarmPerson('mainmon/updataSave', $scope)
                } else {
                    MyFactory.alarmPerson('mainmon/saveIndex', $scope)
                }

            }

            //添加和删除预警接收人
            MyFactory.addAndDelRecevier($scope);

            //添加和删除指标名称
            $scope.addIndex = function () {
                if ($scope.ifAdd) {
                    $scope.addData.index.push({
                        'indexName': '',
                        'quantity': '',
                        'unit': '',
                        'alarmLevel': '',
                        'upperLimit': '',
                        'lowerLimit': '',
                        'sustainTime': '',
                        'indexDesc': ''
                    })
                } else {
                    App.alert('没有指标可添加')
                }

            }

            $scope.delIndex = function (index) {
                $scope.addData.index.splice(index, 1)
            }


            //改变预警接收人
            MyFactory.changeRecUser($scope);

            //初始化主机下拉
            $scope.hostName = function () {
                MyFactory.PostAjax('mainmon/addIndex', '', function (data) {

                    $scope.allMainName = data.data.hostnames;
                    $scope.addData.hostId = $scope.allMainName[0].objId;
                    if (!data.data.indexnames) {
                        $scope.addData.index = [];
                    }
                });
            }
            $scope.hostName();


            //下拉选项可添加和修改的数据
            $scope.upDataList = function () {
                MyFactory.PostAjax('mainmon/showIndex', {
                    'hostId': $scope.addData.hostId
                }, function (data) {

                    if (data.data.indexnames.length == 0) {
                        $scope.addData.index = [];
                        $scope.addData.alarmRecUser = [];
                        $scope.ifAdd = false;

                    } else {
                        $scope.alarmusers = data.data.alarmusers;
                        $scope.indexnames = data.data.indexnames;
                        $scope.addData.index = [{
                            'keyId': data.data.indexnames[0].keyId,
                            'quantity': '',
                            'unit': '百分比',
                            'alarmLevel': '1',
                            'upperLimit': '',
                            'lowerLimit': '',
                            'sustainTime': '',
                            'indexDesc': ''
                        }];
                        if (data.data.alarmusers.length > 0) {
                            $scope.addData.alarmRecUser = [{
                                'rceId': data.data.alarmusers[0].rceId,
                                'phone': data.data.alarmusers[0].phone,
                                'email': data.data.alarmusers[0].email,
                                'userType': data.data.alarmusers[0].userType,
                                'recAlarmLevel1': MyFactory.bool(data.data.alarmusers[0].recAlarmLevel1),
                                'recAlarmLevel2': MyFactory.bool(data.data.alarmusers[0].recAlarmLevel2),
                                'recAlarmLevel3': MyFactory.bool(data.data.alarmusers[0].recAlarmLevel3),
                            }]
                            $scope.ifAdd = true;
                        } else {
                            $scope.addData.alarmRecUser = [];
                            $scope.ifAdd = false;
                        }
                    }
                })
            }

            $scope.GoSystem = function (id) {
                localStorage.setItem('goSystem', id);
                location.href = '#/systemMonitor';
            }

        } else {

            location.href = '#/forbid';
        }
    });
})
//========系统监控==========//
app.controller('systemMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'systemMonitor', function (data) {
        if (data.data.isSuccess) {
            //初始化数据
            $scope.hostId = '';
            $scope.isOk = false; //判断是否获取完表格数据

            $scope.upData = function () {
                //表格相应数据
                //cpu使用
                $scope.cpuIowait = [];
                $scope.cpuSystem = [];
                $scope.cpuUser = [];
                $scope.cpuCpu = [];

                //内存使用
                $scope.memory = [];
                $scope.swap = [];
                //磁盘使用
                $scope.diskData1 = [];
                $scope.diskData2 = [];
                $scope.diskData3 = [];
                $scope.diskData4 = [];
                //网络使用
                $scope.networkRec = [];
                $scope.networkTran = [];
                //cpu负荷
                $scope.cpuLoad = [];
                //磁盘使用的 磁盘名称
                $scope.hdiskName = [];
                $scope.hdiskValue = [];
                //表格x轴显示的时间刻度
                var date = new Date();
                //时间格式转化为时间戳
                function timeChangetype(stringTime) {
                    var timestamp2 = Date.parse(new Date(stringTime));
                    return timestamp2;
                }

                function addMinutes(date, minutes) {
                    minutes = parseInt(minutes);
                    var interTimes = minutes * 60 * 1000;
                    interTimes = parseInt(interTimes);
                    var dateTime = new Date(Date.parse(date) + interTimes);
                    var hour = dateTime.getHours();
                    var min = dateTime.getMinutes();
                    if (min < 10) {
                        min = '0' + min
                    }
                    return hour + ":" + min;
                }
                var datas = [];
                for (var i = 12; i >= 0; i--) {
                    datas.push(addMinutes(date, i * (-5)));
                }
                var year = date.getFullYear(); //获取完整的年份(4位,1970-????)
                var month = date.getMonth() + 1; //获取当前月份(0-11,0代表1月)
                var nowDate = date.getDate(); //获取当前日(1-31)
                var hour = date.getHours(); //获取当前小时数
                var minutes = date.getMinutes(); //获取当前分钟数(0-59)
                var nowtime = year + '/' + month + '/' + nowDate + ' ' + hour + ':' + minutes + ':00'; //獲取當前時間整分鐘
                var endTime = new Date(nowtime).getTime(); //当前分钟的时间戳 单位：毫秒
                var startTime = endTime - 3600000; //1小时前的时间戳
                $scope.startDate = timeChangetype(startTime); //把时间转换为为时间戳
                $scope.endDate = timeChangetype(endTime);
                MyFactory.PostAjax('systemMon/findHost', '', function (data) {
                    $scope.result = data;
                    if ($scope.hostId == '') {
                        $scope.hostId = $scope.result[0].objId;
                    }
                    $scope.tsearchData = {
                        'objId': $scope.hostId,
                        'startDate': $scope.startDate / 1000, //時間戳單位為秒 开始时间秒数以00结尾
                        'endDate': $scope.endDate / 1000, //结束时间以秒数59结尾
                        'interval': 300 //單位為秒
                    }
                    //获取相应的系统信息
                    MyFactory.PostAjax('systemMon/findHostBasic', {
                        'objId': $scope.hostId
                    }, function (data) {
                        $scope.sysData = data;
                    })
                    //获取相应的任务信息
                    MyFactory.PostAjax('systemMon/findHostTask', {
                        'objId': $scope.hostId
                    }, function (data) {
                        $scope.taskData = data;
                    })
                    //获取相应的硬件信息
                    MyFactory.PostAjax('systemMon/findHostHardware', {
                        'objId': $scope.hostId
                    }, function (data) {
                        $scope.hardData = data;
                        $scope.hardData1 = []; //存放总硬盘信息
                        $scope.hardData2 = []; //存放各磁盘信息
                        angular.forEach($scope.hardData, function (item) {
                            if (item.key) {
                                $scope.hardData1.push(item);
                            } else {
                                angular.forEach(item, function (item1) {

                                    $scope.hardData2.push(item1);
                                });

                            }

                        });
                    })
                    //获取相应的资源使用信息（图表数据）
                    MyFactory.PostAjax('systemMon/findHostRecuse', $scope.tsearchData, function (data) {
                        var cpu = data.cpu; //cpu使用率
                        var cpusys = data.cpusys; //cpu系统使用率
                        var cpuuser = data.cpuuser; //cpu用户使用率
                        var iowait = data.iowait; //iowait

                        var cpuload = data.cpuload; //cpu负荷
                        var memuse = data.memuse; //内存使用率
                        var recv = data.recv; //接收网络流量
                        var send = data.send; //发送网络流量
                        var swapuse = data.swapuse; //交换内存使用率
                        var hdisk = data.hdisk; //磁盘使用
                        //	     		  var data=[];

                        angular.forEach(cpuuser, function (item2) {
                            $scope.cpuUser.push(item2.value);

                        })
                        angular.forEach(iowait, function (item1) {
                            $scope.cpuIowait.push(item1.value);

                        });
                        angular.forEach(cpusys, function (item3) {
                            $scope.cpuSystem.push(item3.value);
                        })
                        angular.forEach(cpu, function (item3) {
                            $scope.cpuCpu.push(item3.value);
                        })

                        angular.forEach(memuse, function (item3) {
                            $scope.memory.push(item3.value);
                        })
                        angular.forEach(swapuse, function (item3) {
                            $scope.swap.push(item3.value);
                        })
                        angular.forEach(recv, function (item3) {
                            $scope.networkRec.push(item3.value);
                        })
                        angular.forEach(send, function (item3) {
                            $scope.networkTran.push(item3.value);
                        })
                        angular.forEach(cpuload, function (item2) {
                            $scope.cpuLoad.push(item2.value);

                        })
                        angular.forEach(hdisk, function (item, key) {
                            $scope.hdiskName.push(key);
                            $scope.hdiskValue.push(item);
                        })
                        //cpu图
                        var cpuTime = datas;
                        var data1 = $scope.cpuIowait;
                        var data2 = $scope.cpuSystem;
                        var data3 = $scope.cpuUser;
                        var data4 = $scope.cpuCpu;
                        App.cpuChart(cpuTime, data1, data2, data3, data4);
                        var loadTime = datas;
                        var loadData = $scope.cpuLoad;
                        var title = 'cpu负荷';
                        App.AverageChart(loadTime, loadData, title);

                        //内存使用率
                        var memoryTime = datas;
                        var memorydata1 = $scope.memory;
                        var memorydata2 = $scope.swap;
                        var kedu1 = 1;
                        var dushu1 = 0;
                        App.memoryChart('memory', memoryTime, kedu1, dushu1, memorydata1, memorydata2, '内存使用率', 'Memory', 'Swap');


                        //网络使用
                        var netTime = datas;
                        var netData1 = $scope.networkRec;
                        var netData2 = $scope.networkTran;
                        var kedu = 2;
                        var dushu = 20;
                        App.memoryChart('net', netTime, kedu, dushu, netData1, netData2, '网络流量', 'Recived', 'Transmatted');
                    })
                    //获取相应的进程使用资源信息
                    MyFactory.PostAjax('systemMon/findHostPid', {
                        'objId': $scope.hostId
                    }, function (data) {
                        $scope.progress = data;
                    })
                })
            }

            $scope.upData();
            //是否有下钻
            if (localStorage.getItem('goSystem')) {
                var id = localStorage.getItem('goSystem');
                $scope.hostId = id;

                MyFactory.PostAjax('sysmon/hostSys', {
                    'hostId': $scope.hostId
                }, function () {
                    $scope.result = data.data;
                })
            }

            //选择显示的主机信息
            $scope.changeHost = function () {
                $scope.upData();
            }
            //拖拽滚动
            MyFactory.hostDrag('.system_gunBox', '.system_gunBox .gunDiv');
            MyFactory.hostDrag('.hardware_gunBox', '.hardware_gunBox .gunDiv');
            MyFactory.hostDrag('.task_gunBox', '.task_gunBox .gunDiv');
        } else {

            location.href = '#/forbid';
        }
    });
})

//=======进程监控============//
app.controller('processMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'processMonitor', function (data) {
        if (data.data.isSuccess) {
            //拖拽滚动
            MyFactory.hostDrag('.system_gunBox', '.system_gunBox .gunDiv');
            MyFactory.hostDrag('.hardware_gunBox', '.hardware_gunBox .gunDiv');
            MyFactory.hostDrag('.task_gunBox', '.task_gunBox .gunDiv');

            //初始化数据
            MyFactory.PostAjax('sysmon/showPid', '', function (data) {

                $scope.result = data.data;
                $scope.allMainName = data.data.hostName;
                $scope.hostId = data.data.hostName[0].objId;
            })

            //选择显示的主机信息
            $scope.changeName = function () {
                MyFactory.PostAjax('sysmon/hostPid', {
                    'hostId': $scope.hostId,
                }, function (data) {
                    $scope.result = data.data;
                })
            }

            //添加和删除预警接收人
            $scope.ifAdd = true;
            MyFactory.addAndDelRecevier($scope);
            //添加配置
            $scope.addData = {
                pidName: '',
                alarmLevel: '1',
                quantity: '',
                remark: '',
                upperLimit: '',
                lowerLimit: '',
                'alarmRecUser': [{
                    'rceId': '',
                    'phone': '',
                    'email': '',
                    'userType': '',
                    'recAlarmLevel1': false,
                    'recAlarmLevel2': false,
                    'recAlarmLevel3': false
                }]
            };

            //改变预警接收人
            MyFactory.changeRecUser($scope);

            //点击添加配置
            $scope.edit = function () {

                MyFactory.PostAjax('sysmon/addIndex', {
                    hostId: $scope.hostId
                }, function (data) {
                    //进程名下拉
                    $scope.pidnames = data.data.pidnames;
                    if (data.data.pidnames.length > 0) {
                        $scope.addData.pidName = data.data.pidnames[0].pidName;
                    } else {
                        App.alert('没有进程名可添加')
                    }
                    //预警接收人下拉数据
                    $scope.alarmusers = data.data.alarmusers;
                    //预警接收人显示数据
                    if (data.data.alarmusers.length > 0) {
                        $scope.addData.alarmRecUser = [{
                            'rceId': data.data.alarmusers[0].rceId,
                            'phone': data.data.alarmusers[0].phone,
                            'email': data.data.alarmusers[0].email,
                            'userType': data.data.alarmusers[0].userType,
                            'recAlarmLevel1': MyFactory.bool(data.data.alarmusers[0].recAlarmLevel1),
                            'recAlarmLevel2': MyFactory.bool(data.data.alarmusers[0].recAlarmLevel2),
                            'recAlarmLevel3': MyFactory.bool(data.data.alarmusers[0].recAlarmLevel3),
                        }]
                    } else {
                        $scope.addData.alarmRecUser = [];
                    }

                })
            }

            //保存配置信息
            $scope.editSave = function () {
                $scope.addData.hostId = $scope.hostId;
                var flag = false;
                if ($scope.addData.alarmRecUser.length == 0) {
                    App.alert("预警接收人不能为空")
                }
                //判断预警接收人重名
                var personFlag = false;
                for (var i = 0; i < $scope.addData.alarmRecUser.length; i++) {
                    for (var j = i + 1; j < $scope.addData.alarmRecUser.length; j++) {
                        if ($scope.addData.alarmRecUser[i].rceId == $scope.addData.alarmRecUser[j].rceId) {
                            personFlag = true;
                        }
                    }
                }
                if (personFlag) {
                    App.alert('预警接收人不能重名');
                    return
                }

                var sendData = angular.copy($scope.addData);
                sendData.alarmRecUser = encodeURI(JSON.stringify(sendData.alarmRecUser));

                MyFactory.PostAjax('sysmon/saveIndex', sendData, function (data) {
                    if (data.status == '0') {
                        App.alert(data.msg);
                        $scope.changeName();
                        $("#add1").modal('hide');
                    } else {
                        App.alert(data.msg);
                    }
                })

            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//=======redis监控===========//
app.controller('redisMonitor', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'processMonitor', function (data) {
        if (data.data.isSuccess) {
            //初始化数据
            $scope.searchData = {
                'role': ''
            };
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('redisMon/query', $scope.searchData, function (data) {
                    $scope.loaded = false;
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'redisMon/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                })
            }
            $scope.upData();



            //页数和条数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //添加配置
            $scope.addData = {};
            $scope.addConfig = function () {
                MyFactory.PostAjax('redismon/addIndex', '', function (data) {
                    //ip下拉
                    $scope.redisIps = data.data.redisIps;
                    $scope.addData.redisId = data.data.redisIps[0].redisId;

                    MyFactory.hostSelectIp('redismon/showIndex')

                    MyFactory.PostAjax('redismon/showIndex', {
                        'hostId': $scope.addData.redisId
                    }, function (data) {
                        MyFactory.hostSelectIp($scope, data)
                    })


                })

            }


            //选择redis节点
            $scope.changeRedis = function () {
                MyFactory.PostAjax('redismon/showIndex', {
                    'hostId': $scope.addData.redisId
                }, function (data) {
                    MyFactory.hostSelectIp($scope, data)
                })
            }

            //保存配置
            $scope.editSave = function () {
                MyFactory.hostSaveMonitor('redismon/saveIndex', $scope);
            }

            //添加删除指标，添加删除预警接收人
            MyFactory.hostDelandAdd($scope);
        } else {

            location.href = '#/forbid';
        }
    });
})
//========tomcat监控========//
app.controller('tomcatMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'tomcatMonitor', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                //       pageSize:'5',
                //       pageNo:1
            }
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('tomcatMon/query', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                });
            }
            $scope.upData();



            //页数和条数
            //   MyFactory.selectPage($scope);

            $scope.addData = {};
            //添加配置
            $scope.edit = function () {
                MyFactory.PostAjax('tommon/addIndex', '', function (data) {
                    $scope.hostnames = data.data.hostnames;
                    $scope.tomcatId = data.data.hostnames[0].objId;

                    //拿tomcatId请求数据
                    MyFactory.PostAjax('tommon/showIndex', {
                        'hostId': $scope.tomcatId
                    }, function (data) {
                        MyFactory.hostSelectIp($scope, data);
                    })


                })
            }


            //选择tomcat节点后
            $scope.selectTomcat = function () {
                MyFactory.PostAjax('tommon/showIndex', {
                    'hostId': $scope.tomcatId
                }, function (data) {
                    MyFactory.hostSelectIp($scope, data);
                })
            }


            //保存配置
            $scope.editSave = function () {
                $scope.addData.tomcatId = $scope.tomcatId
                MyFactory.hostSaveMonitor('tommon/saveIndex', $scope);
            }

            //添加删除指标，添加删除预警接收人
            MyFactory.hostDelandAdd($scope);

            $scope.showData = function (item) {
                $scope.searchData = {};
                $scope.searchData.hostId = item.id;
                MyFactory.Date($scope, '#tomcatDate', 'startTime', 'endTime');
                MyFactory.PostAjax('tommon/showInfo', $scope.searchData, function (data) {
                    $scope.showInfo = data.data;
                    $scope.showInfo.tName = item.tName;
                    $scope.showInfo.tIp = item.tIp;
                    $scope.showInfo.tPort = item.tPort;
                    $scope.showInfo.tVersions = item.tVersions;
                    $scope.showInfo.jvmVersions = item.jvmVersions;
                    $scope.showInfo.os = item.os;
                    $scope.showInfo.lastCollectionTime = item.lastCollectionTime;
                })

                //折线图
                var myTime = ['9:15', '9:20', '9:25', '9:30', '9:35', '9:40', '9:45'];
                var myData = [120, 132, 101, 134, 90, 230, 210];
                var myTime1 = ['9:20', '9:25', '9:30', '9:35', '9:40', '9:45', '9:50'];
                var myData1 = [132, 101, 134, 90, 230, 210, 20];
                MyFactory.responseTime('responseTime', '响应时间', myData, myTime, 'blue');
                MyFactory.responseTime('memoryUsage', '内存使用率', myData1, myTime1, 'green')

            }
        } else {

            location.href = '#/forbid';
        }
    });

})

//========oracle监控=======//
app.controller('oracleMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'oracleMonitor', function (data) {
        if (data.data.isSuccess) {
            MyFactory.PostAjax('oraclemmon/showOracle', '', function (data) {
                $scope.result = data.data;
            })
            //添加配置
            $scope.addData = {};
            $scope.edit = function () {
                MyFactory.PostAjax('oraclemmon/addIndex', '', function (data) {
                    MyFactory.hostSelectIp($scope, data);
                })
            }

            //保存配置
            $scope.editSave = function () {
                MyFactory.hostSaveMonitor('oraclemmon/saveIndex', $scope);
            }

            //添加和删除指标和预警接收人
            MyFactory.hostDelandAdd($scope);
        } else {

            location.href = '#/forbid';
        }
    });


})


//========指标监控配置==========//
app.controller('indexMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'indexMonitor', function (data) {
        if (data.data.isSuccess) {
            //初始化数据
            $scope.searchData = {};
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('targetTrigger/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'targetTrigger/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();

            //页数和条数
            MyFactory.selectPage($scope);

            //获取对象类型
            MyFactory.PostAjax('dicDef/getByDicName', {
                'dicName': 'objType'
            }, function (data) {
                $scope.objType = data;
            })

            //下拉级联
            $scope.childObjType = function () {
                $scope.objList = [];
                $scope.addData.objId = '';
                $scope.keyNameList = [];
                $scope.addData.itemId = '';
                $scope.indexUnitList = [];
                $scope.addData.keyId = '';
                $scope.addData.indexUnit = '';
                $scope.addData.quantity = '';
                MyFactory.PostAjax('objectDef/getByObjType', {
                    'objType': $scope.addData.objType
                }, function (data) {
                    $scope.objList = data;
                })
            }

            //点击修改和添加
            $scope.edit = function (popup, item) {
                $scope.popup = popup;
                if (popup == '修改') {
                    $scope.editId = item.triggerId;
                    $scope.isEdit = true;
                    $scope.addData = {};
                    MyFactory.PostAjax('targetTrigger/toUpdate', {
                        'triggerId': item.triggerId
                    }, function (data) {

                        MyFactory.PostAjax('objectDef/getByObjType', {
                            'objType': data.objType
                        }, function (data) {
                            $scope.objList = data;
                        })
                        MyFactory.PostAjax('itemDef/getByObjId', {
                            'objId': data.objId
                        }, function (data) {
                            $scope.keyNameList = data;
                        })

                        MyFactory.PostAjax('itemKeyDef/getByItemId', {
                            'itemId': data.itemId
                        }, function (data) {
                            $scope.indexUnitList = data
                        })
                        $scope.addData.triggerName = data.triggerName;
                        $scope.addData.sustainTime = data.sustainTime;
                        $scope.addData.expressions = data.expressions;
                        $scope.addData.indexDesc = data.indexDesc;
                        $scope.addData.objType = data.objType;
                        $scope.addData.objId = data.objId;
                        $scope.addData.keyId = data.keyId;
                        $scope.addData.itemId = data.itemId;
                        $scope.addData.indexUnit = data.indexUnit;
                        $scope.addData.quantity = data.quantity;

                    })

                } else {
                    $scope.isEdit = false
                    $scope.addData = {
                        keyId: '',
                        objType: '',
                        triggerName: '',
                        sustainTime: '',
                        expressions: '',
                        indexDesc: '',
                        objId: '',
                        itemId: ''
                    };
                }
            }

            //保存修改和添加信息
            $scope.editSave = function () {
                if ($scope.popup == '修改') {
                    var url = 'targetTrigger/update';
                    $scope.addData.triggerId = $scope.editId;
                } else {
                    var url = 'targetTrigger/save';
                }
                if ($scope.addData.keyId == '') {
                    App.alert('指标名称为必选项');
                    return
                }
                if ($scope.addData.triggerName == '') {
                    App.alert('监控名称不能为空');
                    return
                }
                MyFactory.PostAjax(url, $scope.addData, function (data) {
                    if (data.isSuccess == true) {
                        $('#changes').modal('hide');
                        $scope.upData();
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }



            //保存和修改级联
            $scope.getKeyName = function () {
                $scope.keyNameList = [];
                $scope.addData.itemId = '';
                $scope.indexUnitList = [];
                $scope.addData.keyId = '';
                $scope.addData.indexUnit = '';
                $scope.addData.quantity = '';
                MyFactory.PostAjax('itemDef/getByObjId', {
                    'objId': $scope.addData.objId
                }, function (data) {
                    $scope.keyNameList = data;

                })
            }

            $scope.getIndexUnit = function () {
                $scope.indexUnitList = [];
                $scope.addData.indexUnit = '';
                $scope.addData.quantity = '';
                MyFactory.PostAjax('itemKeyDef/getByItemId', {
                    'itemId': $scope.addData.itemId
                }, function (data) {
                    $scope.indexUnitList = data
                })
            }

            $scope.changeIndexUnit = function () {
                for (var i = 0; i < $scope.indexUnitList.length; i++) {
                    if ($scope.indexUnitList[i].keyId == $scope.addData.keyId) {
                        $scope.addData.indexUnit = $scope.indexUnitList[i].indexUnit;
                        $scope.addData.quantity = $scope.indexUnitList[i].quantity;
                    }
                }
            }
        } else {

            location.href = '#/forbid';
        }
    });
})



//========接入汇总监控==========//
app.controller('joinMonitor', function ($scope, MyFactory, $timeout) {

    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'joinMonitor', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {};
            $scope.searchData1 = {};
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('accessReport/query', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                });
            }
            $scope.upData1 = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('accessReport/queryUp', $scope.searchData1, function (data) {
                    $scope.result1 = data;
                    $scope.loaded = false;
                });
            }


            MyFactory.Date($scope, '#joinMonitorDate', 'startDate', 'endDate');
            MyFactory.Date1($scope, '#joinMonitorDate1', 'startDate', 'endDate');

            $scope.upData();
            $scope.upData1();
            $scope.clearTime0 = function (id) {
                $('#' + id).val('');
            }
            $scope.clearTime1 = function () {
                $('#joinMonitorDate1').val('');
            }

            $scope.search = function () {
                var strData = $('#joinMonitorDate').val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.upData();
            };
            $scope.search1 = function () {
                var strData = $('#joinMonitorDate1').val();
                $scope.searchData1.startDate = strData.substring(0, 10);
                $scope.searchData1.endDate = strData.substring(12);
                $scope.upData1();
            };

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                var strData = $('#joinMonitorDate').val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };

            $scope.loadStyle1 = {
                'display': 'none'
            }
            $scope.outExcel1 = function () {
                var strData = $('#joinMonitorDate1').val();
                $scope.searchData1.startDate = strData.substring(0, 10);
                $scope.searchData1.endDate = strData.substring(12);
                $scope.loadStyle1 = {
                    'display': 'block'
                }
                $('#form1').submit();
                $timeout(function () {
                    $scope.loadStyle1 = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });
})
//========短信通道监控==========//
app.controller('smsMonitor', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsMonitor', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {};
            $scope.searchData1 = {};
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('gateReport/query', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                });
            }
            $scope.upData1 = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('gateReport/queryUp', $scope.searchData1, function (data) {
                    $scope.result1 = data;
                    $scope.loaded = false;
                });
            }
            $scope.upData();
            $scope.upData1();
            MyFactory.Date($scope, '#smsMonitorDate', 'startDate', 'endDate');
            MyFactory.Date1($scope, '#smsMonitorDate1', 'startDate', 'endDate');
            $scope.clearTime0 = function (id) {
                $('#' + id).val('');
            }
            $scope.search = function () {
                var strData = $('#smsMonitorDate').val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.upData();
            };
            $scope.search1 = function () {
                var strData = $('#smsMonitorDate1').val();
                $scope.searchData1.startDate = strData.substring(0, 10);
                $scope.searchData1.endDate = strData.substring(12);
                $scope.upData1();
            };

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                var strData = $('#smsMonitorDate').val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            $scope.loadStyle1 = {
                'display': 'none'
            }
            $scope.outExcel1 = function () {
                var strData = $('#smsMonitorDate1').val();
                $scope.searchData1.startDate = strData.substring(0, 10);
                $scope.searchData1.endDate = strData.substring(12);
                $scope.loadStyle1 = {
                    'display': 'block'
                }
                $('#form1').submit();
                $timeout(function () {
                    $scope.loadStyle1 = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });

})


//========优先级队列监控==========//
app.controller('priorityMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'priorityMonitor', function (data) {
        if (data.data.isSuccess) {
            //初始化数据
            $scope.searchData = {
                svrNode: '',
                serviceCode: '',
                gateLinkId: '',
                level: ''
            };
            //获取优先级管理
            MyFactory.PostAjax('priRuleDef/getAll', {}, function (data) {
                $scope.levelData = data;
                $scope.isall = 1;
            })
            $scope.upData = function () {
                $scope.loaded = true;

                MyFactory.PostAjax('priQueue/query', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                    if ($scope.searchData.level == '') {
                        $scope.isall = 1;
                    } else {
                        $scope.isall = 2;
                        $scope.level = [$scope.searchData.level];
                    }


                });
            }
            $scope.upData();


            //业务端下拉列表
            MyFactory.setSms($scope);
            //短信通道
            MyFactory.PostAjax('gateDef/getGateLink', {}, function (data) {
                $scope.showData = data;
            });

        } else {

            location.href = '#/forbid';
        }
    });
})



//========业务端监控==========//
app.controller('businessMonitor', function ($scope, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'businessMonitor', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
            };
            $scope.searchData1 = {
                'svrNode': '',
            };

            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('svrNodeReport/query', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                });
            }
            $scope.upData1 = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('svrNodeReport/queryUp', $scope.searchData1, function (data) {
                    $scope.result1 = data;
                    $scope.loaded = false;
                });
            }
            $scope.upData();
            $scope.upData1();


            MyFactory.Date($scope, '#businessMonitorDate', 'startDate', 'endDate');
            MyFactory.Date1($scope, '#businessMonitorDate1', 'startDate', 'endDate');
            $scope.clearTime0 = function (id) {
                $('#' + id).val('');
            }
            //业务端下拉列表
            MyFactory.setSms($scope);


            $scope.search = function () {
                var strData = $('#businessMonitorDate').val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.upData();
            };
            $scope.search1 = function () {
                var strData = $('#businessMonitorDate1').val();
                $scope.searchData1.startDate = strData.substring(0, 10);
                $scope.searchData1.endDate = strData.substring(12);
                $scope.upData1();
            };

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                var strData = $('#businessMonitorDate').val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //导出表格信息
            $scope.loadStyle1 = {
                'display': 'none'
            }
            $scope.outExcel1 = function () {
                var strData = $('#businessMonitorDate1').val();
                $scope.searchData1.startDate = strData.substring(0, 10);
                $scope.searchData1.endDate = strData.substring(12);
                $scope.loadStyle1 = {
                    'display': 'block'
                }
                $('#form1').submit();
                $timeout(function () {
                    $scope.loadStyle1 = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });

})



//========对象监控==========//
app.controller('objManage', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'objManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'objName': ''
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('objectDef/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    if (callback) {
                        callback();
                    }
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'objectDef/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();

            //页数和条数
            MyFactory.selectPage($scope);

            //获取对象类型
            MyFactory.PostAjax('dicDef/getByDicName', {
                'dicName': 'objType'
            }, function (data) {
                $scope.objType = data;
            })

            //删除
            $scope.delete = function (id) {
                $scope.deleteId = id
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('objectDef/delete', {
                    'objId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    }
                    App.alert(data.msg);
                })
            }

            //点击修改或者添加
            $scope.edit = function (popup, id) {
                $scope.popup = popup;
                if (popup == '添加') {
                    $scope.addData = {
                        'objName': '',
                        'objType': '',
                        'remark': ''
                    }
                    $scope.addData.objType = $scope.objType[0].DICVALUE;
                } else {
                    $scope.editId = id;
                    MyFactory.PostAjax('objectDef/toUpdate', {
                        'objId': id
                    }, function (data) {
                        $scope.addData = {
                            'objName': data.objName,
                            'objType': data.objType,
                            'remark': data.remark
                        }
                    })
                }

            }

            //保存修改或添加信息
            $scope.editSave = function () {

                var url = ''
                if ($scope.popup == '修改') {
                    url = 'objectDef/update';
                    $scope.addData.objId = $scope.editId;
                } else {
                    url = 'objectDef/save';
                }

                if ($scope.addData.objName == '') {
                    App.promptOne(App.d('#objName'), '请添加对象名称');
                    return
                }

                MyFactory.PostAjax(url, $scope.addData, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData();
                        $('#add1').modal('hide')
                    }
                    App.alert(data.msg)
                })

            }
        } else {

            location.href = '#/forbid';
        }
    });
})



//========子对象管理==========//
app.controller('childObjManage', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'childObjManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'objType': '',
                'objId': ''
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                if ($scope.searchData.objId == null) {
                    $scope.searchData.objId = '';
                }
                MyFactory.PostAjax('itemDef/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    if (callback) {
                        callback();
                    }
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'itemDef/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();
            //页数和条数
            MyFactory.selectPage($scope);

            //删除
            $scope.delete = function (id) {
                $scope.deleteId = id
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('itemDef/delete', {
                    'itemId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    }
                    App.alert(data.msg);
                })
            }
            //获取对象类型
            MyFactory.PostAjax(' dicDef/getByDicName', {
                'dicName': 'objType'
            }, function (data) {
                $scope.objtypeList = data;
            })

            //相应对象类型的对象
            $scope.childObjType = function () {
                MyFactory.PostAjax('objectDef/getByObjType', {
                    'objType': $scope.searchData.objType
                }, function (data) {
                    $scope.objList = data;
                })
            }

            //获取子对象类型
            MyFactory.PostAjax('dicDef/getByDicName', {
                'dicName': 'itemType'
            }, function (data) {
                $scope.objType = data;
            })

            //获取所有的对象
            MyFactory.PostAjax('objectDef/getAll', '', function (data) {
                $scope.objListAll = data;
            })
            //保存和修改级联
            $scope.getKeyName = function () {
                MyFactory.PostAjax('itemDef/getByObjId', {
                    'objId': $scope.addData.objId
                }, function (data) {
                    $scope.keyNameList = data
                })
            }

            //
            $scope.isShowSelect = true;
            MyFactory.PostAjax('gateDef/getUnusedGateByService', '', function (data) {
                $scope.showData = data;
            })
            $scope.changeChildType = function () {
                if ($scope.addData.itemType == '20') {
                    $scope.isShowSelect = false;

                }
            }



            //点击修改和添加
            $scope.edit = function (popup, id) {
                $scope.popup = popup;
                if (popup == '修改') {
                    $scope.editId = id;
                    MyFactory.PostAjax('itemDef/toUpdate', {
                        'itemId': id
                    }, function (data) {
                        if (data.itemType == '20') {
                            $scope.isShowSelect = false;
                        }
                        $scope.addData = {
                            'itemName': data.itemName,
                            'objId': data.objId,
                            'itemType': data.itemType,
                            'applications': data.applications,
                            'remark': data.remark
                        }
                    })
                } else {
                    $scope.addData = {
                        'itemName': '',
                        'objId': '',
                        'itemType': '',
                        'applications': '',
                        'remark': ''
                    }
                }
            }

            //点击保存
            $scope.editSave = function () {
                var url = '';
                if ($scope.popup == '修改') {
                    $scope.addData.itemId = $scope.editId;
                    url = 'itemDef/update';
                } else {
                    url = 'itemDef/save';
                }

                if ($scope.addData.itemName == '') {
                    App.promptOne(App.d('#itemName'), '子对象名不能为空');
                    return
                }
                if ($scope.addData.applications == '') {
                    App.promptOne(App.d('#applications'), '应用标识不能为空');
                    return
                }
                MyFactory.PostAjax(url, $scope.addData, function (data) {
                    if (data.isSuccess == true) {
                        $('#add1').modal('hide');
                        $scope.upData();
                    }
                    App.alert(data.msg)
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });

})

//========属性管理==========//
app.controller('attributeManage', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'attributeManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'objId': '',
                'itemId': '',
                'objType': ''
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                if ($scope.searchData.objId == null) {
                    $scope.searchData.objId = '';
                }
                if ($scope.searchData.itemId == null) {
                    $scope.searchData.itemId = '';
                }
                MyFactory.PostAjax('itemKeyDef/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    if (callback) {
                        callback();
                    }
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'itemKeyDef/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();
            //页数和条数
            MyFactory.selectPage($scope);

            //删除
            $scope.delete = function (id) {
                $scope.deleteId = id
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('itemKeyDef/delete', {
                    'keyId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    }
                    App.alert(data.msg);
                })
            }
            //获取对象类型
            MyFactory.PostAjax(' dicDef/getByDicName', {
                'dicName': 'objType'
            }, function (data) {
                $scope.objtypeList = data;
            })

            //相应对象类型的对象
            $scope.childObjType = function () {
                MyFactory.PostAjax('objectDef/getByObjType', {
                    'objType': $scope.searchData.objType
                }, function (data) {
                    $scope.objList = data;
                })
            }

            //获取所有的对象
            MyFactory.PostAjax('objectDef/getAll', '', function (data) {
                $scope.objListAll = data;
            })

            //获取子对象下拉
            $scope.getKeyName = function (message) {
                var list = '';
                message == 'addData' ? list = 'keyNameList1' : list = 'keyNameList';
                $scope[message].itemId = '';
                if ($scope[message].objId == null) {
                    $scope[message].objId = '';
                    $scope[message].itemId = ''
                }
                MyFactory.PostAjax('itemDef/getByObjId', {
                    'objId': $scope[message].objId
                }, function (data) {
                    $scope[list] = data;
                })
            }

            //点击修改和添加
            $scope.edit = function (popup, id) {
                $scope.popup = popup;
                if (popup == '修改') {
                    $scope.editId = id;
                    MyFactory.PostAjax('itemKeyDef/toUpdate', {
                        'keyId': id
                    }, function (data) {
                        MyFactory.PostAjax('itemDef/getByObjId', {
                            'objId': data.objId
                        }, function (data) {
                            $scope.keyNameList1 = data
                        })
                        $scope.addData = data;
                    })
                } else {
                    $scope.addData = {
                        'key': '',
                        'keyCn': '',
                        'itemId': '',
                        'seq': '',
                        'valueType': '',
                        'precision': '',
                        'units': '',
                        'updatetime': '',
                        'history': '',
                        'trends': '',
                        'remark': '',
                        'trendsdimUnit': '',
                        'trendsdim': ''
                    }
                }
            }


            //保存添加和修改信息
            $scope.editSave = function () {
                var url = '';
                if ($scope.popup == '修改') {
                    url = 'itemKeyDef/update';
                    $scope.addData.keyId = $scope.editId;
                } else {
                    url = 'itemKeyDef/save';
                };

                var input = App.d('.modal-body .input');
                var bool = true;
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '' || (input[i].value).indexOf('?') != -1) {
                        bool = false && bool;
                    }
                }
                if (!bool) {
                    App.prompt(input);
                    return
                }
                MyFactory.PostAjax(url, $scope.addData, function (data) {
                    if (data.isSuccess == true) {
                        $('#add1').modal('hide');
                        $scope.upData()
                    }
                    App.alert(data.msg)
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//========监控管理==========//
app.controller('setupManage', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'setupManage', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'objId': '',
                'itemId': '',
                'objType': ''
            };
            $scope.upData = function (callback) {
                $scope.loaded = true;
                if ($scope.searchData.objId == null) {
                    $scope.searchData.objId = '';
                }
                if ($scope.searchData.itemId == null) {
                    $scope.searchData.itemId = '';
                }
                MyFactory.PostAjax('trigger/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    if (callback) {
                        callback();
                    }
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'trigger/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();
            //页数和条数
            MyFactory.selectPage($scope);

            //删除
            $scope.delete = function (id) {
                $scope.deleteId = id
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('trigger/delete', {
                    'triggerId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    }
                    App.alert(data.msg);
                })
            }


            //获取对象类型
            MyFactory.PostAjax(' dicDef/getByDicName', {
                'dicName': 'objType'
            }, function (data) {
                $scope.objtypeList = data;
            })

            //相应对象类型的对象
            $scope.childObjType = function (data) {
                var list = '';
                data == 'addData' ? list = 'objList1' : list = 'objList'
                if ($scope[data].objId == null) {
                    $scope[data].objId = '';
                    $scope[data].itemId = ''
                }
                if ($scope[data].objId == '') {
                    $scope[data].itemId = ''
                }
                MyFactory.PostAjax('objectDef/getByObjType', {
                    'objType': $scope[data].objType
                }, function (data) {
                    $scope[list] = data;
                })
            }

            //获取子对象下拉
            $scope.getKeyName = function (data) {
                var list = '';
                data == 'addData' ? list = 'keyNameList1' : list = 'keyNameList'
                if ($scope[data].objId == null) {
                    $scope[data].objId = '';
                    $scope[data].itemId = '';
                }
                if ($scope[data].objId == '') {
                    $scope[data].itemId = '';
                }
                MyFactory.PostAjax('itemDef/getByObjId', {
                    'objId': $scope[data].objId
                }, function (data) {
                    $scope[list] = data
                })
            }
            //级联
            $scope.getIndexUnit = function () {
                MyFactory.PostAjax('itemKeyDef/getByItemId', {
                    'itemId': $scope.addData.itemId
                }, function (data) {
                    $scope.indexUnitList = data
                })
            }


            //点击修改和添加
            $scope.edit = function (popup, id) {
                $scope.popup = popup;
                if (popup == '修改') {
                    $scope.editId = id;
                    $scope.isDisable = false;
                    MyFactory.PostAjax('trigger/toUpdate', {
                        'triggerId': id
                    }, function (data) {
                        MyFactory.PostAjax('itemDef/getByObjId', {
                            'objId': data.objId
                        }, function (data) {
                            $scope.keyNameList1 = data
                        });
                        //获取对象
                        MyFactory.PostAjax('objectDef/getByObjType', {
                            'objType': data.objType
                        }, function (data) {
                            $scope.objList1 = data;
                        })
                        MyFactory.PostAjax('itemKeyDef/getByItemId', {
                            'itemId': data.itemId
                        }, function (data) {
                            $scope.indexUnitList = data
                        })


                        $scope.addData = data;

                        if (data.alarmLevel == '') {
                            $scope.addData.alarmLevel = '';
                        } else if (data.alarmLevel == 1) {
                            $scope.addData.alarmLevel = '1';
                        } else if (data.alarmLevel == 2) {
                            $scope.addData.alarmLevel = '2';
                        } else {
                            $scope.addData.alarmLevel = '3';
                        }
                        if (data.emailFlag == 1) {
                            $scope.addData.emailFlag = true;
                        } else {
                            $scope.addData.emailFlag = false;
                        }
                        if (data.smFlag == 1) {
                            $scope.addData.smFlag = true;
                        } else {
                            $scope.addData.smFlag = false;
                        }

                    })
                } else {
                    $scope.isDisable = true;
                    $scope.addData = {
                        'objType': '',
                        'objId': '',
                        'itemId': '',
                        'keyId': '',
                        'lowerLimit': '',
                        'upperLimit': '',
                        'expressions': '',
                        'sustainTime': '',
                        'times': '',
                        'alarmLevel': '',
                        'smFlag': false,
                        'emailFlag': false,
                        'indexDesc': '',
                        'warnMsg': ''
                    }
                }
            }


            //保存添加和修改信息
            $scope.editSave = function () {
                var url = '';
                if ($scope.popup == '修改') {
                    url = 'trigger/update';
                    $scope.addData.triggerId = $scope.editId;
                } else {
                    url = 'trigger/save';
                };

                var input = App.d('.modal-body .input');
                var bool = true;
                for (var i = 0; i < input.length; i++) {

                    if (input[i].value == '') {

                        bool = false && bool;

                    }

                }
                if (!bool) {
                    App.prompt(input);
                    return
                }
                if ($scope.addData.emailFlag == true) {
                    $scope.addData.emailFlag = 1;
                } else {
                    $scope.addData.emailFlag = 0;
                }
                if ($scope.addData.smFlag == true) {
                    $scope.addData.smFlag = 1;
                } else {
                    $scope.addData.smFlag = 0;
                }
                MyFactory.PostAjax(url, $scope.addData, function (data) {
                    if (data.isSuccess == true) {
                        $('#add1').modal('hide');
                        $scope.upData()
                    }
                    App.alert(data.msg)
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });

})



//========预警接收人管理==========//
app.controller('warnPersonManage', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'warnPersonManage', function (data) {
        if (data.data.isSuccess) {
            $scope.objId = '';
            //获取对象类型
            MyFactory.PostAjax('dicDef/getByDicName', {
                'dicName': 'objType'
            }, function (data) {
                $scope.objType = data;
            })

            MyFactory.PostAjax('users/getAll', '', function (data) {
                $scope.users = data;

            })

            //下拉级联
            $scope.childObjType = function () {
                $scope.result = [];
                $scope.objList = [];
                $scope.objId = '';
                MyFactory.PostAjax('objectDef/getByObjType', {
                    'objType': $scope.searchData.objType
                }, function (data) {
                    $scope.objList = data;
                })
            }

            //选择对象信息
            $scope.result = [];
            $scope.showData = function () {
                MyFactory.PostAjax('warnRecv/getByObjId', {
                    'objId': $scope.objId
                }, function (data) {
                    $scope.result = data;
                    //显示相应的电话和邮件
                    for (var i = 0; i < $scope.result.length; i++) {
                        for (var j = 0; j < $scope.users.length; j++) {
                            if ($scope.result[i].userId == $scope.users[j].userId) {
                                $scope.result[i].phoneNumber = $scope.users[j].phoneNumber;
                                $scope.result[i].mailBox = $scope.users[j].mailBox;

                            }
                        }
                    }

                    for (var i = 0; i < $scope.result.length; i++) {
                        $scope.result[i].warnLevel1 == '1' ? $scope.result[i].warnLevel1 = true : $scope.result[i].warnLevel1 = false;
                        $scope.result[i].warnLevel2 == '1' ? $scope.result[i].warnLevel2 = true : $scope.result[i].warnLevel2 = false;
                        $scope.result[i].warnLevel3 == '1' ? $scope.result[i].warnLevel3 = true : $scope.result[i].warnLevel3 = false;
                    }

                    $scope.cancelData = angular.copy($scope.result);
                })

            }

            //选择预警接收人
            $scope.changeUser = function (index, phone) {
                //不能重名
                for (var i = 0; i < $scope.result.length; i++) {
                    if (i != index) {
                        if ($scope.result[i].userId == $scope.result[index].userId) {
                            App.alert("预警接收人不能重名");
                            $scope.result[index].userId = ''
                        }
                    }
                }

                //显示相应的电话和邮件
                for (var i = 0; i < $scope.users.length; i++) {
                    if ($scope.users[i].userId == $scope.result[index].userId) {
                        $scope.result[index].phoneNumber = $scope.users[i].phoneNumber;
                        $scope.result[index].mailBox = $scope.users[i].mailBox;
                    }
                }

            }

            $scope.addTr = function () {
                if ($scope.objId == '') {
                    App.alert('请选择要监控的对象')
                    return
                };
                $scope.result.push({
                    'userId': '',
                    'recId': '',
                    'userType': '1',
                    'warnLevel1': false,
                    'warnLevel2': false,
                    'warnLevel3': false,
                })
            }


            //删除
            $scope.delTr = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                $scope.result.splice($scope.deleteIndex, 1);
            }


            //取消，退回未操作的状态
            $scope.cancel = function () {
                $scope.result = $scope.cancelData;
            }



            //保存
            $scope.save = function () {
                if ($scope.objId == '') {
                    App.alert('请选择对象');
                    return
                }

                var isSave = true;
                for (var i = 0; i < $scope.result.length; i++) {
                    if ($scope.result[i].userId == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.alert('请选择预警接收人');
                    return
                }

                var saveData = angular.copy($scope.result);
                for (var i = 0; i < saveData.length; i++) {
                    saveData[i].warnLevel1 ? saveData[i].warnLevel1 = '1' : saveData[i].warnLevel1 = '0';
                    saveData[i].warnLevel2 ? saveData[i].warnLevel2 = '1' : saveData[i].warnLevel2 = '0';
                    saveData[i].warnLevel3 ? saveData[i].warnLevel3 = '1' : saveData[i].warnLevel3 = '0';
                }
                var sendData = {
                    'objId': $scope.objId
                };
                sendData.warnRecvs = encodeURI(JSON.stringify(saveData));

                MyFactory.PostAjax('warnRecv/save', sendData, function (data) {
                    App.alert(data.msg)
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//========预警接收人明细==========//
app.controller('warnDetailMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'warnDetailMonitor', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'objType': '',
                'dealStatus': ''
            }
            //时间插件
            MyFactory.Date($scope, '#warnMonitorDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/innormalEvent/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    if (callback) {
                        callback()
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/innormalEvent/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();
            //页数选择及显示条数
            MyFactory.selectPage($scope);
            //查询
            $scope.search = function () {
                var strData = $("#warnMonitorDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
            //获取对象类型
            MyFactory.PostAjax('/dicDef/getByDicName', {
                "dicName": "objType"
            }, function (data) {
                $scope.listData1 = data;
            })

            //弹出处理框
            $scope.handle = function (objId, warnLevel, recid, value) {
                //处理相关数据
                $scope.handleData = {
                    userId: '', //预警人工号
                    dealStatus: value, //处理状态
                    remark: '', //说明
                    eventId: '' //预警id
                }
                $scope.handleData.eventId = recid;
                MyFactory.PostAjax('warnRecv/getByObjId', {
                    'objId': objId,
                    'warnLevel': warnLevel
                }, function (data) {
                    $scope.warnRecv = data;
                    $scope.handleData.userId = data[0].userId;
                })
            }
            //保存
            $scope.handleSave = function () {
                //获取当前账号的工位id
                var user = localStorage.getItem('userid');
                if ($scope.handleData.userId != user) {
                    App.promptOne(document.querySelector('#userid'), '请选择您自己的工号');
                    return
                } //校验工号是否为当前账户工号
                if ($scope.handleData.dealStatus == '') {
                    App.promptOne(document.querySelector('#dealStatus'), '处理状态不能为空');
                    return
                } //检验是否选择处理状态
                if ($scope.handleData.remark == '') {
                    App.promptOne(document.querySelector('#desc'), '说明不能为空');
                    return
                } //校验说明是否有填

                //信息无误开始请求
                MyFactory.PostAjax('innormalEvent/change', $scope.handleData, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData();
                        App.alert(data.msg, function () {
                            $('#add1').modal('hide');
                        })
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
            //是否有下钻
            if (localStorage.getItem('warnCollectDetail')) {

                var str = localStorage.getItem('warnCollectDetail');
                var warnCollectDetail = JSON.parse(str);
                $scope.searchData = {
                    'startDate': warnCollectDetail.startDate,
                    'endDate': warnCollectDetail.endDate,
                    'objType': warnCollectDetail.objType,
                    'dealStatus': warnCollectDetail.dealStatus
                };

                $('#warnMonitorDate').val(warnCollectDetail.startDate + ' - ' + warnCollectDetail.endDate);
                $scope.upData();
                localStorage.removeItem('warnCollectDetail');

            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//========预警汇总监控==========//
app.controller('warnCollectMonitor', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'warnCollectMonitor', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'objType': '',
            }
            //时间插件
            MyFactory.Date($scope, '#warnCollectDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/innormalEventRep/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    if (callback) {
                        callback()
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/innormalEventRep/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                        $scope.loaded = false;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);
            //查询
            $scope.search = function () {
                var strData = $("#warnCollectDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
            //获取对象类型
            MyFactory.PostAjax('/dicDef/getByDicName', {
                "dicName": "objType"
            }, function (data) {
                $scope.listData1 = data;
            })

            //汇总预警下钻到明细页面
            $scope.toMx = function (date, objtype, status) {
                var obj = {
                    'startDate': date,
                    'endDate': date,
                    'objType': objtype,
                    'dealStatus': status
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('warnCollectDetail', str);
                location.href = '#/warnDetailMonitor';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//============业务短信发送量逐级监控 月===========//
app.controller('smsGraduallyMonitor', function ($scope, appService, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsGraduallyMonitor', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'svrNodes': ''
            }

            //初始化当前时间
            var date = new Date;
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            if (month < 10) {
                month = '0' + month;
            }
            $('.yearValueFrom').text(year)
            $('.yearValueTo').text(year)
            for (var i = 0; i < 12; i++) {
                if ($('.monthToBox>li').eq(i).text() == month) {
                    $('.monthToBox>li').eq(i).addClass('monthToActiveClick')
                }
            }
            $('.monthFromBox>li').eq(0).addClass('monthToActiveClick')

            $('.formYearMonth').val(year + '-' + '01')
            $('.toYearMonth').val(year + '-' + month)

            $('.selectYearMonthClick').val($('.formYearMonth').val() + " - " + $('.toYearMonth').val())

            //点击弹出选择框
            $('.selectYearMonthClick').click(function () {
                if ($('.selectYearMonth').hasClass('selectYearMonthActive')) {
                    $('.selectYearMonth').removeClass('selectYearMonthActive')
                } else {
                    $('.selectYearMonth').addClass('selectYearMonthActive')
                }
            })
            //点击左箭头，起始年份减1
            $('.subYearFrom').click(function () {
                var yearValueFrom = $('.yearValueFrom').text();
                yearValueFrom--;
                $('.yearValueFrom').text(yearValueFrom);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthFromBox>li').eq(i).hasClass('monthToActiveClick')) {
                        $('.formYearMonth').val(yearValueFrom + '-' + $('.monthFromBox>li').eq(i).text())
                    }
                }
            })
            //点击右箭头，起始年份加1
            $('.addYearFrom').click(function () {
                var yearValueFrom = +$('.yearValueFrom').text();
                yearValueFrom++;
                $('.yearValueFrom').text(yearValueFrom);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthFromBox>li').eq(i).hasClass('monthToActiveClick')) {
                        $('.formYearMonth').val(yearValueFrom + '-' + $('.monthFromBox>li').eq(i).text())
                    }
                }
            })
            //点击左箭头，结束年份减1
            $('.subYearTo').click(function () {
                var yearValueTo = +$('.yearValueTo').text();
                yearValueTo--;
                $('.yearValueTo').text(yearValueTo);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthToBox>li').eq(i).hasClass('monthToActiveClick')) {
                        $('.toYearMonth').val(yearValueTo + '-' + $('.monthToBox>li').eq(i).text())
                    }
                }
            })
            //点击右箭头，结束年份加1
            $('.addYearTo').click(function () {
                var yearValueTo = +$('.yearValueTo').text();
                yearValueTo++;
                $('.yearValueTo').text(yearValueTo);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthToBox>li').eq(i).hasClass('monthToActiveClick')) {
                        $('.toYearMonth').val(yearValueTo + '-' + $('.monthToBox>li').eq(i).text())
                    }
                }
            })
            //起始月份，移入改变样式
            $(".monthFromBox>li").mouseover(function () {
                $(this).addClass('monthToActive').siblings().removeClass('monthToActive');
            });
            //移出月份框,保留点击样式,移除mouseover样式
            $(".monthFromBox").mouseout(function () {
                $(".monthFromBox>li").removeClass('monthToActive');
            });
            //结束月份，移入改变样式
            $(".monthToBox>li").mouseover(function () {
                $(this).addClass('monthToActive').siblings().removeClass('monthToActive');
            });
            //移出月份框,保留点击样式,移除mouseover样式
            $(".monthToBox").mouseout(function () {
                $('.monthToBox>li').removeClass('monthToActive');
            });
            //点击第一个选框里的月份
            $(".monthFromBox>li").click(function () {
                $('.formYearMonth').val($('.yearValueFrom').text() + '-' + $(this).text())
                $(this).addClass('monthToActiveClick').siblings().removeClass('monthToActiveClick')

            });
            //点击第二个选框里的月份
            $(".monthToBox>li").click(function () {
                $('.toYearMonth').val($('.yearValueTo').text() + '-' + $(this).text())
                $(this).addClass('monthToActiveClick').siblings().removeClass('monthToActiveClick')
            });

            //点击取消，关闭弹框
            $(".closeBtn").click(function () {
                $('.selectYearMonth').addClass('selectYearMonthActive')
            });
            //点击確定，关闭弹框,改变值
            $(".okBtn").click(function () {
                $('.selectYearMonth').addClass('selectYearMonthActive')
                $('.selectYearMonthClick').val($('.formYearMonth').val() + ' - ' + $('.toYearMonth').val())
                $scope.searchData.startDate = $('.selectYearMonthClick').val().substr(0, 7);
                $scope.searchData.endDate = $('.selectYearMonthClick').val().substr(10, 12);
            });
            $scope.searchData.startDate = $('.selectYearMonthClick').val().substr(0, 7);
            $scope.searchData.endDate = $('.selectYearMonthClick').val().substr(10, 12);

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjaxs('/sendSm/queryMMCount', $scope.searchData, function (data) {
                    $scope.result = data[0].result;
                    $scope.psData = data[1].svrNameList;
                    $scope.tysData = data[1].dateList;
                    $scope.preData = data[1].preDateList;
                    $scope.selPage = data[0].pageNo;
                    $scope.count = data[0].totalCount;
                    $scope.totalCount = data[0].totalPages;

                    $scope.loaded = false;
                    $scope.mmsData = [];
                    for (var i = 0; i < data[1].svrNameList.length; i++) {
                        var obj = {};
                        obj.name = data[1].svrNameList[i];
                        obj.type = 'bar';
                        obj.barCateGoryGap = 20;
                        obj.data = data[1].lists[i];
                        $scope.mmsData.push(obj);
                    }

                    // 多项条形统计图
                    var myChart = echarts.init(document.getElementById('smsMonth'));
                    var option = {
                        title: {
                            text: '每月各个系统短信发送量统计'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            // type: 'scroll',
                            align: 'left',
                            top: 30,
                            data: $scope.psData
                        },
                        toolbox: {
                            show: true,
                        },
                        calculable: true,
                        dataZoom: [{
                            type: 'slider',
                            show: true,
                            start: 30,
                            end: 100,
                            handleSize: 8
                        },
                        {
                            type: 'inside',
                            start: 70,
                            end: 100
                        },
                        {
                            type: 'slider',
                            show: true,
                            yAxisIndex: 0,
                            filterMode: 'empty',
                            width: 12,
                            height: '70%',
                            handleSize: 8,
                            showDataShadow: false,
                            left: '93%'
                        }
                        ],
                        xAxis: [{
                            type: 'category',
                            data: $scope.tysData,
                        }],
                        yAxis: [{
                            type: 'value'
                        }],
                        series: $scope.mmsData
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    if (option && typeof option === "object") {
                        myChart.setOption(option, true);
                    }
                    function everyClick(param, i, url) { //程序这边的url需要传入
                        if (param.dataIndex == i) {
                            appService.preDay = $scope.preData[i];
                            location.href = url;
                        }
                    }
                    //增加监听事件
                    function eConsole(param) {
                        if (typeof param.seriesIndex != 'undefined') {
                            if (param.type == 'click') {
                                var peiLenght = option.xAxis[0].data.length;
                                for (var i = 0; i < peiLenght; i++) {
                                    everyClick(param, i, '#/smsGraduallyMonitorDay')
                                }
                            }
                        }
                    }
                    myChart.on("click", eConsole);

                    if (callback) {
                        callback()
                    }

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/sendSm/queryMMCount', $scope.searchData, function (data) {
                        $scope.result = data[0].result;
                        $scope.loaded = false;
                    })
                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //下拉数据加载
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            });

            $timeout(function () {
                $('#svrNodes').fSelect();
                $('.fs-wrap').css("marginLeft", "44px");
            }, 500);

            //查询
            $scope.search = function (e) {
                var svrNodes = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            svrNodes.push($(this).attr("data-value"));
                        })
                        $scope.searchData.svrNodes = svrNodes.toString();
                        $scope.upData();
                    }

                } else {
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        svrNodes.push($(this).attr("data-value"));
                    })
                    $scope.searchData.svrNodes = svrNodes.toString();
                    $scope.upData();
                }
            }

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });
})

//============业务短信发送量逐级监控 日===========//
app.controller('smsGraduallyMonitorDay', function ($scope, appService, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsGraduallyMonitorDay', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'svrNodes': '',
                'preDateInfo': ''
            }
            // 判断是否传值
            if (appService.preDay) {
                $scope.searchData.preDateInfo = appService.preDay;
                var obj = appService.preDay;
                var str = obj.slice(0, 4);
                // str = str - 1;
                // str = str + 1;
                obj = obj.slice(5, 7);
                obj = obj - 1;
                obj = obj + 1;
                if (obj < 10) {
                    obj = '0' + obj;
                }
                var curMonthDays = new Date(str, obj, 0).getDate();
                $scope.searchData.startDate = appService.preDay + '-' + '01';
                $scope.searchData.endDate = appService.preDay + '-' + curMonthDays;
            }
            // 时间插件
            MyFactory.Date4($scope, '#smsGraduallyMonitorDay', 'startDate', 'endDate', $scope.searchData.startDate, $scope.searchData.endDate);
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjaxs('/sendSm/queryDDCount', $scope.searchData, function (data) {
                    $scope.result = data[0].result;
                    $scope.psData = data[1].svrNameList;
                    $scope.tysData = data[1].dateList;
                    $scope.preData = data[1].preDateList;
                    $scope.selPage = data[0].pageNo;
                    $scope.count = data[0].totalCount;
                    $scope.totalCount = data[0].totalPages;
                    $scope.loaded = false;
                    $scope.mmsData = [];
                    for (var i = 0; i < data[1].svrList.length; i++) {
                        var obj = {};
                        obj.name = data[1].svrNameList[i];
                        obj.type = 'bar';
                        obj.barCateGoryGap = 20;
                        obj.data = data[1].lists[i];
                        $scope.mmsData.push(obj);
                    }

                    // 多项条形统计图
                    var myChart = echarts.init(document.getElementById('smsDay'));
                    var option = {
                        title: {
                            text: '每日各个系统短信发送量统计'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            type: 'scroll',
                            align: 'left',
                            top: 30,
                            data: $scope.psData
                        },
                        toolbox: {
                            show: true,
                        },
                        calculable: true,
                        dataZoom: [{
                            type: 'slider',
                            show: true,
                            start: 10,
                            end: 100,
                            handleSize: 8
                        },
                        {
                            type: 'inside',
                            start: 80,
                            end: 100
                        },
                        {
                            type: 'slider',
                            show: true,
                            yAxisIndex: 0,
                            filterMode: 'empty',
                            width: 12,
                            height: '70%',
                            handleSize: 8,
                            showDataShadow: false,
                            left: '93%'
                        }
                        ],
                        xAxis: [{
                            type: 'category',
                            data: $scope.tysData,

                        }],
                        yAxis: [{
                            type: 'value'
                        }],
                        series: $scope.mmsData
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);

                    function everyClick(param, i, url) { //程序这边的url需要传入
                        if (param.dataIndex == i) {
                            appService.preTime = $scope.preData[i];
                            location.href = url;
                        }
                    }
                    //增加监听事件
                    function eConsole(param) {
                        if (typeof param.seriesIndex != 'undefined') {
                            if (param.type == 'click') {
                                var peiLenght = option.xAxis[0].data.length;
                                // 获取总共给分隔的扇形数
                                for (var i = 0; i < peiLenght; i++) {
                                    everyClick(param, i, '#/smsGraduallyMonitorTime')
                                }
                            }

                        }
                    }
                    myChart.on("click", eConsole);
                    if (callback) {
                        callback()
                    }

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/sendSm/queryDDCount', $scope.searchData, function (data) {
                        $scope.result = data[0].result;
                        $scope.loaded = false;
                    })
                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //下拉数据加载
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            });

            $timeout(function () {
                $('#svrNodes').fSelect();
                $('.fs-wrap').css("marginLeft", "44px");
            }, 500);

            //时间调用
            $('#smsGraduallyMonitorDay').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsGraduallyMonitorDay").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(13));

            });

            //查询
            $scope.search = function (e) {
                var svrNodes = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#smsGraduallyMonitorDay").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(13);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            svrNodes.push($(this).attr("data-value"));
                        })
                        $scope.searchData.svrNodes = svrNodes.toString();
                        $scope.upData();
                    }

                } else {
                    var strData = $("#smsGraduallyMonitorDay").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(13);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        svrNodes.push($(this).attr("data-value"));
                    })
                    $scope.searchData.svrNodes = svrNodes.toString();
                    $scope.upData();
                }
            }

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });
})

//============业务短信发送量逐级监控 时===========//
app.controller('smsGraduallyMonitorTime', function ($scope, appService, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsGraduallyMonitorTime', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'svrNodes': '',
                'preDateInfo': ''
            }

            // 判断是否传值
            if (appService.preTime) {
                $scope.searchData.preDateInfo = appService.preTime;
                $scope.searchData.startDate = appService.preTime + ' ' + '00';
                $scope.searchData.endDate = appService.preTime + ' ' + '23';
            }

            // 时间插件
            MyFactory.Date3($scope, '#smsGraduallyMonitorTime', 'startDate', 'endDate', $scope.searchData.startDate, $scope.searchData.endDate);
            $('.minuteselect').attr('disabled', 'disabled');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjaxs('/sendSm/queryHHCount', $scope.searchData, function (data) {
                    $scope.result = data[0].result;
                    $scope.psData = data[1].svrNameList;
                    $scope.tysData = data[1].dateList;
                    $scope.preData = data[1].preDateList;
                    $scope.selPage = data[0].pageNo;
                    $scope.count = data[0].totalCount;
                    $scope.totalCount = data[0].totalPages;
                    $scope.loaded = false;
                    $scope.mmsData = [];
                    for (var i = 0; i < data[1].svrNameList.length; i++) {
                        var obj = {};
                        obj.name = data[1].svrNameList[i];
                        obj.type = 'bar';
                        obj.data = data[1].lists[i];
                        obj.barCateGoryGap = 20;
                        $scope.mmsData.push(obj);
                    }

                    // 多项条形统计图
                    var myChart = echarts.init(document.getElementById('smsTime'));
                    var option = {
                        title: {
                            text: '每时各个系统短信发送量统计'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        legend: {
                            align: 'left',
                            top: 30,
                            data: $scope.psData
                        },
                        toolbox: {
                            show: true,
                        },
                        calculable: true,
                        dataZoom: [{
                            type: 'slider',
                            show: true,
                            start: 10,
                            end: 100,
                            handleSize: 8
                        },
                        {
                            type: 'inside',
                            start: 90,
                            end: 100
                        },
                        {
                            type: 'slider',
                            show: true,
                            yAxisIndex: 0,
                            filterMode: 'empty',
                            width: 12,
                            height: '70%',
                            handleSize: 8,
                            showDataShadow: false,
                            left: '93%'
                        }
                        ],
                        xAxis: [{
                            type: 'category',
                            data: $scope.tysData,
                        }],
                        yAxis: [{
                            type: 'value'
                        }],
                        series: $scope.mmsData
                    };
                    // 使用刚指定的配置项和数据显示图表。
                    myChart.setOption(option);

                    function everyClick(param, i, url) { //程序这边的url需要传入
                        if (param.dataIndex == i) {
                            appService.preBranch = $scope.preData[i];
                            location.href = url;
                        }
                    }
                    //增加监听事件
                    function eConsole(param) {
                        if (typeof param.seriesIndex != 'undefined') {
                            if (param.type == 'click') {
                                var peiLenght = option.xAxis[0].data.length;
                                var patLength = option.legend.data.length;
                                // 获取总共给分隔的扇形数
                                for (var i = 0; i < peiLenght; i++) {
                                    for (var j = 0; j < patLength; j++) {
                                        everyClick(param, i, '#/smsGraduallyMonitorBranch');
                                    }
                                }
                            }

                        }
                    }
                    myChart.on("click", eConsole);
                    if (callback) {
                        callback()
                    }

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/sendSm/queryHHCount', $scope.searchData, function (data) {
                        $scope.result = data[0].result;
                        $scope.loaded = false;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //下拉数据加载
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            });

            $timeout(function () {
                $('#svrNodes').fSelect();
                $('.fs-wrap').css("marginLeft", "44px");
            }, 500);

            //查询
            $scope.search = function (e) {
                var svrNodes = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            svrNodes.push($(this).attr("data-value"));
                        })
                        $scope.searchData.svrNodes = svrNodes.toString();
                        $scope.upData();
                    }

                } else {
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        svrNodes.push($(this).attr("data-value"));
                    })
                    $scope.searchData.svrNodes = svrNodes.toString();
                    $scope.upData();
                }
            }

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });
})

//============业务短信发送量逐级监控 分===========//
app.controller('smsGraduallyMonitorBranch', function ($scope, appService, MyFactory, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsGraduallyMonitorBranch', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'svrNodes': '',
                'preDateInfo': ''
            }

            // 判断是否传值
            if (appService.preBranch) {
                $scope.searchData.preDateInfo = appService.preBranch;
                $scope.searchData.startDate = appService.preBranch + ':' + '00';
                $scope.searchData.endDate = appService.preBranch + ':' + '59';
            }

            // 时间插件
            MyFactory.Date5($scope, '#smsGraduallyMonitorBranch', 'startDate', 'endDate', $scope.searchData.startDate, $scope.searchData.endDate);
            $('.hourselect').attr('disabled', 'disabled');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/sendSm/queryMICount', $scope.searchData, function (data) {
                    $scope.result = data[0].result;
                    $scope.psData = data[1].svrNameList;
                    $scope.tysData = data[1].dateList;
                    $scope.preData = data[1].preDateList;
                    $scope.selPage = data[0].pageNo;
                    $scope.count = data[0].totalCount;
                    $scope.totalCount = data[0].totalPages;
                    $scope.loaded = false;
                    $scope.mmsData = [];
                    for (var i = 0; i < data[1].svrNameList.length; i++) {
                        var obj = {};
                        obj.name = data[1].svrNameList[i];
                        obj.type = 'bar';
                        obj.data = data[1].lists[i];
                        obj.barCateGoryGap = 20;
                        $scope.mmsData.push(obj);
                    }

                    // 多项条形统计图
                    App.barShapeChart('smsBranch', $scope.psData, $scope.tysData, $scope.mmsData, '每分各个系统短信发送量统计');
                    if (callback) {
                        callback()
                    }

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/sendSm/queryMICount', $scope.searchData, function (data) {
                        $scope.result = data[0].result;
                        $scope.loaded = false;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //下拉数据加载
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            });

            $timeout(function () {
                $('#svrNodes').fSelect();
                $('.fs-wrap').css("marginLeft", "44px");
            }, 500);

            //查询
            $scope.search = function (e) {
                var svrNodes = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            svrNodes.push($(this).attr("data-value"));
                        })
                        $scope.searchData.svrNodes = svrNodes.toString();
                        $scope.upData();
                    }

                } else {
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        svrNodes.push($(this).attr("data-value"));
                    })
                    $scope.searchData.svrNodes = svrNodes.toString();
                    $scope.upData();
                }
            }

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });

})

//========运营分析工作台开始==========//
//========超长短信统计==========//
app.controller('smsStatistics', function ($scope, $timeout, $http, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsStatistics', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.setSms($scope);

            $scope.searchData = {
                'serviceCode': '',
                'startDate': '',
                'endDate': '',
                'svrNode': '',
                'lastLength': '',
                'isSvrNode': '',
                'isServiceCode': ''
            }
            //输入框默认4字符
            $scope.searchData.lastLength = 4;

            MyFactory.Date($scope, '#smsStatisticsDate', 'startDate', 'endDate');

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('longSmsRep/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'longSmsRep/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();

            //选择条数和页数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                if ($("#SmFrom").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';
                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if ($("#ServiceCode").prop("checked")) {
                    $scope.searchData.isServiceCode = '1';
                } else {
                    $scope.searchData.isServiceCode = '';
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //选择类型
            $scope.upCheck = function () {
                //来源端
                $("#SmFrom").change(function () {
                    if ($("#SmFrom").prop("checked")) {
                        $scope.searchData.isSvrNode = '1';
                    } else {
                        $scope.searchData.isSvrNode = '';
                    }
                    if ($("#ServiceCode").prop("checked")) {
                        $scope.searchData.isServiceCode = '1';
                    } else {
                        $scope.searchData.isServiceCode = '';
                    }
                    $scope.upData();
                })
                //业务类型
                $("#ServiceCode").change(function () {
                    if ($("#ServiceCode").prop("checked")) {
                        $scope.searchData.isServiceCode = '1';
                    } else {
                        $scope.searchData.isServiceCode = '';
                    }
                    if ($("#SmFrom").prop("checked")) {
                        $scope.searchData.isSvrNode = '1';
                    } else {
                        $scope.searchData.isSvrNode = '';
                    }
                    $scope.upData();
                })
            }
            $scope.upCheck();

            $scope.showLongContent = function (svrNode, serviceCode, Ttime) {
                var searchData = {
                    'svrNode': svrNode,
                    'serviceCode': serviceCode,
                    'sendTimeDate': Ttime,
                    'lastLength': $scope.searchData.lastLength
                }
                var Data = JSON.stringify(searchData);
                localStorage.setItem('searchData', Data);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-smsDetails').css('color', '#fff');
                location.href = '#/smsDetails';
            }


            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        var strData = $("#smsStatisticsDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        if ($scope.searchData.svrNode == "") {
                            $scope.searchData.serviceCode = "";
                        }
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    var strData = $("#smsStatisticsDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    if ($scope.searchData.svrNode == "") {
                        $scope.searchData.serviceCode = "";
                    }
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }


            }

            //时间调用

            $('#smsStatisticsDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsStatisticsDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
        } else {

            location.href = '#/forbid';
        }
    });
})
//========超长短信明细==========//
app.controller('smsDetails', function ($scope, $timeout, $http, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsDetails', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
                'startDate': '',
                'endDate': '',
                'userNo': '',
                'lastLength': '4'
            }

            //业务端下拉列表
            //    MyFactory.setSms($scope);
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            });
            MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                $scope.listData2 = data;
            });

            //短信级联
            $scope.getSms = function () {
                //        $scope.searchData.serviceCode="";
                MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                    "svrNode": $scope.searchData.svrNode
                }, function (data) {
                    $scope.listData2 = data;
                })
            }

            //初始化时间
            MyFactory.Date($scope, '#smsDetailDate', 'startDate', 'endDate');

            $scope.upData = function (callback) {
                var end = $scope.searchData.endDate;
                var start = $scope.searchData.startDate;

                function getTime2Time($time1, $time2) {
                    var time1 = arguments[0],
                        time2 = arguments[1];
                    time1 = Date.parse(time1) / 1000;
                    time2 = Date.parse(time2) / 1000;
                    var time_ = time1 - time2;
                    return (time_ / (3600 * 24));
                }
                var days = getTime2Time(end, start);
                if (days > 31) {
                    App.alert('一次查询时间范围不能超过31天！');
                } else {
                    $scope.loaded = true;
                    MyFactory.PostAjax('longSmsRec/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'longSmsRec/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })
                    });
                }

            }

            $scope.$on("$routeChangeSuccess", function (event, next, current) {
                if (localStorage.getItem('searchData')) {
                    var localData = JSON.parse(localStorage.getItem('searchData'));
                    if (current.loadedTemplateUrl.indexOf('smsStatistics') > 0) {

                        $scope.searchData = {
                            'svrNode': localData.svrNode,
                            'serviceCode': localData.serviceCode,
                            'startDate': localData.sendTimeDate,
                            'endDate': localData.sendTimeDate,
                            'lastLength': localData.lastLength
                        }
                        $scope.searchData.pageSize = '5';

                        $('#smsDetailDate').val(localData.sendTimeDate + ' - ' + localData.sendTimeDate);

                        $scope.upData();
                        localStorage.removeItem('searchData')
                    }

                } else {

                    $scope.searchData.pageSize = '5';

                    $scope.upData();
                }
            });


            //选择条数和页数
            MyFactory.selectPage($scope);




            // $scope.upData();
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                var d = {};
                var aa = $('#form').serializeArray();
                $.each(aa, function () {
                    d[this.name] = this.value;
                });
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        var strData = $("#smsDetailDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        if ($scope.searchData.svrNode == "") {
                            $scope.searchData.serviceCode = "";
                        }
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    var strData = $("#smsDetailDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    if ($scope.searchData.svrNode == "") {
                        $scope.searchData.serviceCode = "";
                    }
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }

            }

            //时间调用

            $('#smsDetailDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsDetailDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            $scope.showSmContent = function (content) {
                $scope.showSmsMessage = content;
            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//========无效用户统计==========//
app.controller('userStatistics', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'userStatistics', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                //'failReason':'',
                'startDate': '',
                'endDate': '',
            }
            MyFactory.Date($scope, '#userDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('invalidUserRep/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.obj = data.obj;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'invalidUserRep/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();

            //选择条数和页数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                MyFactory.Date($scope, '#userDate', 'startDate', 'endDate');
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function () {
                // 	MyFactory.Date($scope,'#userDate','startDate','endDate');
                var strData = $("#userDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
            //时间调用
            $('#userDate').daterangepicker(null, function (start, end, label) {
                MyFactory.Date($scope, '#userDate', 'startDate', 'endDate');
                var strData = $("#userDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);

            });

            $scope.GoDetail = function (newInvalidNum, delInvalidNum, tTime) {
                var invalidUser = {
                    'newInvalidNum': newInvalidNum,
                    'delInvalidNum': delInvalidNum,
                    'tTime': tTime
                }
                var str = JSON.stringify(invalidUser);
                localStorage.setItem('invalidUser', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-userDetails').css('color', '#fff');
                location.href = '#/userDetails';
            }
            //总条数下钻
            $scope.toDetail = function (startDate, endDate) {
                var obj = {
                    'startDate': startDate,
                    'endDate': endDate
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('wxUserDetails', str);
                $('.wxNum a').css('color', 'rgba(163,175,183,.9)');
                //      $('.nav-dsSmsDetails').css('color','#fff');
                location.href = '#/userDetails';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})
//========无效用户明细==========//
app.controller('userDetails', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'userDetails', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {};

            MyFactory.Date($scope, '#userDetailDate', 'startDate', 'endDate');

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('invalidUserRec/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'invalidUserRec/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                    //回调
                    if (callback) {
                        callback();
                    }
                });
            }

            //判断进来的链接进行处理显示的信息

            if (localStorage.getItem('invalidUser')) {
                var str = localStorage.getItem('invalidUser');
                var invalidUser = JSON.parse(str);
                $scope.searchData = {
                    'startDate': invalidUser.tTime,
                    'endDate': invalidUser.tTime,
                    'newInvalidNum': invalidUser.newInvalidNum,
                    'delInvalidNum': invalidUser.delInvalidNum,
                };
                $('#userDetailDate').val(invalidUser.tTime + ' - ' + invalidUser.tTime);
                $scope.upData()
                $scope.searchData.pageSize = '5';
                localStorage.removeItem('invalidUser');

            }
            if (localStorage.getItem('wxUserDetails')) {
                var str = localStorage.getItem('wxUserDetails');
                var wxUserDetails = JSON.parse(str);
                $scope.searchData = {
                    'startDate': wxUserDetails.startDate,
                    'endDate': wxUserDetails.endDate,
                };
                if (wxUserDetails.startDate == '') {
                    $('#userDetailDate').val('');
                } else {
                    $('#userDetailDate').val(wxUserDetails.startDate + ' - ' + wxUserDetails.endDate);
                }

                $scope.upData()
                $scope.searchData.pageSize = '5';
                localStorage.removeItem('wxUserDetails');
            } else {
                $scope.searchData.pageSize = '5';
                $scope.upData();
            }



            //选择条数和页数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        //清除掉下钻的参数
                        $scope.searchData.newInvalidNum = '';
                        $scope.searchData.delInvalidNum = '';

                        var strData = $("#userDetailDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    //清除掉下钻的参数
                    $scope.searchData.newInvalidNum = '';
                    $scope.searchData.delInvalidNum = '';

                    var strData = $("#userDetailDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }

            }
            //时间调用
            $('#userDetailDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#userDetailDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
        } else {

            location.href = '#/forbid';
        }
    });

})
//========无效号码激活明细==========//
app.controller('numActivationDetails', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'numActivationDetails', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
            }
            MyFactory.Date($scope, '#numDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('numActivationRec/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'numActivationRec/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }
            $scope.upData();

            //选择条数和页数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function () {
                var strData = $("#numDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
            //时间调用
            $('#numDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#numDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
        } else {

            location.href = '#/forbid';
        }
    });
})
//========下发流量统计==========//
app.controller('dsTrafficStatistics', function ($scope, $timeout, $http, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'dsTrafficStatistics', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.setSms($scope);


            //短信通道
            MyFactory.PostAjax('gateDef/getGateLink', {}, function (data) {
                $scope.showData = data;
            });
            $scope.searchData = {
                'gateLinkId': '',
                'svrNode': '',
                'serviceCode': '',
                'startDate': '',
                'endDate': '',
                'isSvrNode': '',
                'isServiceType': '',
                'isGateLink': '',
            }
            MyFactory.Date($scope, '#dsTrafficStatisticsDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('downFlowRep/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'downFlowRep/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                    var gateLinkId = $scope.searchData.gateLinkId;
                    var svrNode = $scope.searchData.svrNode;
                    var serviceCode = $scope.searchData.serviceCode;
                    $scope.searchCode = {
                        "gateLinkId": gateLinkId,
                        "svrNode": svrNode,
                        "serviceCode": serviceCode
                    };
                });
            }
            $scope.upData();

            //选择条数和页数
            MyFactory.selectPage($scope);

            //选择类型
            $("#source").change(function () {
                if ($("#source").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';
                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if ($("#businessType").prop("checked")) {
                    $scope.searchData.isServiceType = '1';
                } else {
                    $scope.searchData.isServiceType = '';
                }
                if ($("#access").prop("checked")) {
                    $scope.searchData.isGateLink = '1';
                } else {
                    $scope.searchData.isGateLink = '';
                }
                $scope.upData();
            })
            //业务类型
            $("#businessType").change(function () {
                if ($("#businessType").prop("checked")) {
                    $scope.searchData.isServiceType = '1';
                } else {
                    $scope.searchData.isServiceType = '';
                }
                if ($("#source").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';
                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if ($("#access").prop("checked")) {
                    $scope.searchData.isGateLink = '1';
                } else {
                    $scope.searchData.isGateLink = '';
                }
                $scope.upData();
            })
            //通道
            $("#access").change(function () {
                if ($("#access").prop("checked")) {
                    $scope.searchData.isGateLink = '1';
                } else {
                    $scope.searchData.isGateLink = '';
                }
                if ($("#source").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';
                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if ($("#businessType").prop("checked")) {
                    $scope.searchData.isServiceType = '1';
                } else {
                    $scope.searchData.isServiceType = '';
                }
                $scope.upData();
            })
            //}
            //$scope.upCheck();


            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                //来源端
                if ($("#source").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';
                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if ($("#businessType").prop("checked")) {
                    $scope.searchData.isServiceType = '1';
                } else {
                    $scope.searchData.isServiceType = '';
                }
                if ($("#access").prop("checked")) {
                    $scope.searchData.isGateLink = '1';
                } else {
                    $scope.searchData.isGateLink = '';
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function () {
                var strData = $("#dsTrafficStatisticsDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
            //时间调用
            $('#dsTrafficStatisticsDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#dsTrafficStatisticsDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            //下钻
            $scope.GodsSms = function (time, sendFail, sendSuc, recvFail, recvSuc, recvNone, svrNode, serviceCode, gateLinkId) {
                var svrNode1, serviceCode, gateLinkId1;
                if ($scope.searchData.isSvrNode == '') { //判断业务端是否被勾选，勾选的话传自身这条数据返回的参数带到明细，否则，传查询条件的参数
                    svrNode1 = $scope.searchCode.svrNode;
                } else {
                    svrNode1 = svrNode;
                }
                if ($scope.searchData.isServiceType == '') {
                    serviceCode1 = $scope.searchCode.serviceCode;
                } else {
                    serviceCode1 = serviceCode;
                }
                if ($scope.searchData.isGateLink == '') {
                    gateLinkId1 = $scope.searchCode.gateLinkId;
                } else {
                    gateLinkId1 = gateLinkId;
                }

                var obj = {
                    'tTime': time,
                    'sendFail': sendFail,
                    'sendSuc': sendSuc,
                    'recvFail': recvFail,
                    'recvSuc': recvSuc,
                    'recvNone': recvNone,
                    'svrNode': svrNode1,
                    'serviceCode': serviceCode1,
                    'gateLinkId': gateLinkId1
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('dsSmsDetails', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-dsSmsDetails').css('color', '#fff');
                location.href = '#/dsSmsDetails';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//========下发短信明细==========//
app.controller('dsSmsDetails', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'dsSmsDetails', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            });
            MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                $scope.listData2 = data;
            });

            //短信级联
            $scope.getSms = function () {
                MyFactory.PostAjax('/serviceCodeDef/getBySvrNode', {
                    "svrNode": $scope.searchData.svrNode
                }, function (data) {
                    $scope.listData2 = data;
                })
            }

            //短信通道
            MyFactory.PostAjax('gateDef/getGateLink', {}, function (data) {
                $scope.showData = data;
            });
            $scope.searchData = {
                'limitCount': '500',
                'svrNode': '',
                'serviceCode': '',
                'startDate': '',
                'endDate': '',
                'userNo': '',
                'gateLinkId': '',
                'smContent': '',
            }
            MyFactory.Date($scope, '#dsSmsDetailsDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                var end = $scope.searchData.endDate;
                var start = $scope.searchData.startDate;

                function getTime2Time($time1, $time2) {
                    var time1 = arguments[0],
                        time2 = arguments[1];
                    time1 = Date.parse(time1) / 1000;
                    time2 = Date.parse(time2) / 1000;
                    var time_ = time1 - time2;
                    return (time_ / (3600 * 24));
                }
                var days = getTime2Time(end, start);
                if (days > 31) {
                    App.alert('一次查询时间范围不能超过31天！');
                } else {
                    $scope.loaded = true;
                    MyFactory.PostAjax('downSmRec/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'downSmRec/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    });
                }

            }

            //判断本地缓存显示的下钻信息
            //下行流量统计下钻
            if (localStorage.getItem('dsSmsDetails')) {
                var str = localStorage.getItem('dsSmsDetails');
                var dsSmsDetails = JSON.parse(str);
                //            MyFactory.getServiceCode($scope,'listData2',dsSmsDetails.svrNode);
                $scope.searchData = {
                    'startDate': dsSmsDetails.tTime,
                    'endDate': dsSmsDetails.tTime,
                    'sendFail': dsSmsDetails.sendFail,
                    'sendSuc': dsSmsDetails.sendSuc,
                    'recvFail': dsSmsDetails.recvFail,
                    'recvSuc': dsSmsDetails.recvSuc,
                    'recvNone': dsSmsDetails.recvNone,
                    'svrNode': dsSmsDetails.svrNode,
                    'serviceCode': dsSmsDetails.serviceCode,
                    'gateLinkId': dsSmsDetails.gateLinkId
                };
                $('#dsSmsDetailsDate').val(dsSmsDetails.tTime + ' - ' + dsSmsDetails.tTime);
                $scope.upData();

                localStorage.removeItem('dsSmsDetails');

                //年报表下钻
            } else if (localStorage.getItem('YtoDs')) {
                var str = localStorage.getItem('YtoDs');
                var YtoDs = JSON.parse(str);
                if (YtoDs.tTime != '') {
                    var startTime = YtoDs.tTime + '-01-01';
                    var endTime = YtoDs.eTime + '-12-31';
                    $('#dsSmsDetailsDate').val(startTime + ' - ' + endTime);
                } else {
                    var startTime = '';
                    var endTime = '';
                    $('#dsSmsDetailsDate').val('');
                }
                $scope.searchData = {
                    'startDate': startTime,
                    'endDate': endTime,
                    'recvFail': YtoDs.recvFail,
                    'recvSuc': YtoDs.recvSuc,
                    'recvNone': YtoDs.recvNone,
                    'gateLinkId': YtoDs.gateLinkId
                };


                $scope.upData();

                localStorage.removeItem('YtoDs');

                //月报表下钻
            } else if (localStorage.getItem('MtoDs')) {
                var str = localStorage.getItem('MtoDs');
                var MtoDs = JSON.parse(str);
                var Mon = parseInt(MtoDs.tTime.substr(5, 8));
                if (MtoDs.tTime != '') {
                    if (Mon == 12) {
                        //            	    alert(111111);
                        var Stime = MtoDs.tTime.substr(0, 7) + '-01';
                        var Etime = MtoDs.eTime.substr(0, 7);
                        var EtimeShow = MtoDs.eTime.substr(0, 7) + '-31';
                    } else if (Mon >= 9) {
                        //            		alert(2222222);
                        var Stime = MtoDs.tTime.substr(0, 7) + '-01';
                        var Etime = MtoDs.eTime.substr(0, 5) + (Mon + 1);
                        var EtimeShow = MtoDs.eTime.substr(0, 5) + (Mon + 1) + '-01';
                    } else {
                        //            		alert(MtoDs.eTime.substr(0,5));
                        var Stime = MtoDs.tTime.substr(0, 5) + '0' + Mon + '-01';
                        var Etime = MtoDs.eTime.substr(0, 5) + (Mon + 1);
                        var EtimeShow = MtoDs.eTime.substr(0, 5) + '0' + (Mon + 1) + '-01';
                    }
                    $('#dsSmsDetailsDate').val(Stime + ' - ' + EtimeShow);

                } else {
                    var Stime = '';
                    var Etime = '';
                    $('#dsSmsDetailsDate').val('');
                }



                $scope.searchData = {
                    'startDate': MtoDs.tTime,
                    'endDate': Etime,
                    'recvFail': MtoDs.recvFail,
                    'dateFormat': 'month',
                    'recvSuc': MtoDs.recvSuc,
                    'recvNone': MtoDs.recvNone,
                    'gateLinkId': MtoDs.gateLinkId

                };

                $scope.upData();

                localStorage.removeItem('MtoDs');

                //如果没有下钻显示初始化信息
            } else {

                $scope.searchData.pageSize = '5';
                $scope.upData();
            }

            //选择条数和页数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        // 清除下钻查询参数
                        $scope.searchData.sendFail = "";
                        $scope.searchData.sendSuc = "";
                        $scope.searchData.recvFail = "";
                        $scope.searchData.recvSuc = "";
                        $scope.searchData.recvNone = "";
                        //                   $scope.searchData.gateLinkId="";
                        $scope.searchData.dateFormat = "";
                        var strData = $("#dsSmsDetailsDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    // 清除下钻查询参数
                    $scope.searchData.sendFail = "";
                    $scope.searchData.sendSuc = "";
                    $scope.searchData.recvFail = "";
                    $scope.searchData.recvSuc = "";
                    $scope.searchData.recvNone = "";
                    //                   $scope.searchData.gateLinkId="";
                    $scope.searchData.dateFormat = "";
                    var strData = $("#dsSmsDetailsDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }

            }
            //时间调用
            $('#dsSmsDetailsDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#dsSmsDetailsDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            $scope.showSmContent = function (content) {
                $scope.showSmsMessage = content;
            }
        } else {

            location.href = '#/forbid';
        }
    });
})
//========上行流量统计==========//
app.controller('upTrafficStatistics', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'upTrafficStatistics', function (data) {
        if (data.data.isSuccess) {
            // 访问权限
            MyFactory.GetAjaxs('users/authentication', 'dsSmsDetails', function (data) {
                if (data.data.isSuccess) {
                } else {

                    location.href = '#/forbid';
                }
            });
            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            })
            //短信通道
            MyFactory.PostAjax('gateDef/getGateLink', {}, function (data) {
                $scope.showData = data;
            });


            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
                'startDate': '',
                'endDate': '',
                'gateLinkId': '',
                'isSvrNode': '',
                'isGateLink': '',
            }
            MyFactory.Date($scope, '#upTrafficStatisticsDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('upFlowRep/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'upFlowRep/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                    var gateLinkId = $scope.searchData.gateLinkId;
                    var svrNode = $scope.searchData.svrNode;
                    var serviceCode = $scope.searchData.serviceCode;
                    $scope.searchCode = {
                        "gateLinkId": gateLinkId,
                        "svrNode": svrNode,
                        "serviceCode": serviceCode
                    };

                });
            }
            $scope.upData();

            //选择条数和页数
            MyFactory.selectPage($scope);
            //来源端
            $scope.showsa = true;
            $("#source").change(function () {

                if ($("#source").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';
                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if ($("#access").prop("checked")) {
                    $scope.searchData.isGateLink = '1';
                } else {
                    $scope.searchData.isGateLink = '';
                }
                if (($scope.searchData.isSvrNode == '') && ($scope.searchData.isGateLink == '')) {
                    $scope.showsa = true;
                } else {
                    $scope.showsa = false;
                }


                $scope.upData();
            })
            //通道
            $("#access").change(function () {
                if ($("#access").prop("checked")) {
                    $scope.searchData.isGateLink = '1';
                } else {
                    $scope.searchData.isGateLink = '';
                }
                if ($("#source").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';

                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if (($scope.searchData.isSvrNode == '') && ($scope.searchData.isGateLink == '')) {
                    $scope.showsa = true;
                } else {
                    $scope.showsa = false;
                }

                $scope.upData();
            })
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                if ($("#source").prop("checked")) {
                    $scope.searchData.isSvrNode = '1';
                } else {
                    $scope.searchData.isSvrNode = '';
                }
                if ($("#access").prop("checked")) {
                    $scope.searchData.isGateLink = '1';
                } else {
                    $scope.searchData.isGateLink = '';
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function () {
                var strData = $("#upTrafficStatisticsDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }
            //时间调用
            $('#upTrafficStatisticsDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#upTrafficStatisticsDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            $scope.GoupSmsDetail = function (time, upNone, upSuc, upFail, svrNode, gateLinkId) {
                var svrNode1, gateLinkId1;
                if ($scope.searchData.isSvrNode == '') {
                    svrNode1 = $scope.searchCode.svrNode;
                } else {
                    svrNode1 = svrNode;
                }
                if ($scope.searchData.isGateLink == '') {
                    gateLinkId1 = $scope.searchCode.gateLinkId;
                } else {
                    gateLinkId1 = gateLinkId;
                }
                var obj = {
                    'tTime': time,
                    'upNone': upNone,
                    'upSuc': upSuc,
                    'upFail': upFail,
                    'svrNode': svrNode1,
                    'gateLinkId': gateLinkId1
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('upSmsDetail', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-upSmsStatistics').css('color', '#fff');
                location.href = '#/upSmsStatistics';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})
//========上行短信明细==========//
app.controller('upSmsStatistics', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'upSmsStatistics', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            })


            //短信通道
            MyFactory.PostAjax('gateDef/getGateLink', {}, function (data) {
                $scope.showData = data;
            });
            $scope.searchData = {
                'svrNode': '',
                'gateLinkId': '',
                'startDate': '',
                'userNo': '',
                'endDate': '',
                'smContent': '',
            }
            MyFactory.Date($scope, '#upSmsStatisticsDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('upSmRec/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'upSmRec/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })
                });
            }


            //判断本地缓存是否有下钻显示的信息
            //上行流量统计下钻
            if (localStorage.getItem('upSmsDetail')) {

                var str = localStorage.getItem('upSmsDetail');
                var upSmsDetail = JSON.parse(str);
                $scope.searchData = {
                    'startDate': upSmsDetail.tTime,
                    'endDate': upSmsDetail.tTime,
                    'upNone': upSmsDetail.upNone,
                    'upSuc': upSmsDetail.upSuc,
                    'upFail': upSmsDetail.upFail,
                    'svrNode': upSmsDetail.svrNode,
                    'gateLinkId': upSmsDetail.gateLinkId
                };

                $('#upSmsStatisticsDate').val(upSmsDetail.tTime + ' - ' + upSmsDetail.tTime);
                $scope.upData();

                localStorage.removeItem('upSmsDetail');
                //年报表下钻
            } else if (localStorage.getItem('YtoUp')) {
                var str = localStorage.getItem('YtoUp');
                var YtoUp = JSON.parse(str);
                if (YtoUp.tTime != '') {
                    var startTime = YtoUp.tTime + '-01-01';
                    var endTime = YtoUp.tTime + '-12-31';
                    $('#upSmsStatisticsDate').val(startTime + ' - ' + endTime);
                } else {
                    var startTime = '';
                    var endTime = '';
                    $('#upSmsStatisticsDate').val('');
                }
                $scope.searchData = {
                    'startDate': startTime,
                    'endDate': endTime,
                    'gateLinkId': YtoUp.gateLinkId
                };
                $scope.upData();

                localStorage.removeItem('YtoUp');

                //月报表下钻
            } else if (localStorage.getItem('MtoUp')) {
                var str = localStorage.getItem('MtoUp');
                var MtoUp = JSON.parse(str);
                var Mon = parseInt(MtoUp.tTime.substr(5, 8));
                if (MtoUp.tTime != '') {
                    if (Mon == 12) {
                        var Stime = MtoUp.tTime.substr(0, 7) + '-01';
                        var Etime = MtoUp.eTime.substr(0, 7);
                        var EtimeShow = MtoUp.eTime.substr(0, 7) + '-31';
                    } else if (Mon >= 9) {

                        var Stime = MtoUp.tTime.substr(0, 7) + '-01';
                        var Etime = MtoUp.eTime.substr(0, 5) + (Mon + 1);
                        var EtimeShow = MtoUp.eTime.substr(0, 5) + (Mon + 1) + '-01';
                    } else {

                        var Stime = MtoUp.tTime.substr(0, 5) + '0' + Mon + '-01';
                        var Etime = MtoUp.eTime.substr(0, 5) + (Mon + 1);
                        var EtimeShow = MtoUp.eTime.substr(0, 5) + '0' + (Mon + 1) + '-01';
                    }
                    $('#upSmsStatisticsDate').val(Stime + ' - ' + EtimeShow);

                } else {
                    var Stime = '';
                    var Etime = '';
                    $('#upSmsStatisticsDate').val('');
                }

                $scope.searchData = {
                    'startDate': MtoUp.tTime,
                    'endDate': Etime,
                    'dateFormat': 'month',
                    'gateLinkId': MtoUp.gateLinkId
                };

                $scope.upData();

                localStorage.removeItem('MtoUp');


                //没有下钻的情况初始化
            } else {
                $scope.searchData.pageSize = '5';
                $scope.upData();
            }

            //选择条数和页数
            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        // 清除下钻参数
                        $scope.searchData.upNone = "";
                        $scope.searchData.upSuc = "";
                        $scope.searchData.upFail = "";
                        $scope.searchData.upTotal = "";
                        //                $scope.searchData.gateLinkId="";
                        $scope.searchData.dateFormat = "";

                        var strData = $("#upSmsStatisticsDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    // 清除下钻参数
                    $scope.searchData.upNone = "";
                    $scope.searchData.upSuc = "";
                    $scope.searchData.upFail = "";
                    $scope.searchData.upTotal = "";
                    //                $scope.searchData.gateLinkId="";
                    $scope.searchData.dateFormat = "";

                    var strData = $("#upSmsStatisticsDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }

            }
            //时间调用
            $('#upSmsStatisticsDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#upSmsStatisticsDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            $scope.showSmContent = function (content) {
                $scope.showSmsMessage = content;
            }
        } else {

            location.href = '#/forbid';
        }
    });
})
//========结算月报表==========//
app.controller('settlementStatementM', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'settlementStatementM', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': $('#startDate').val(),
                'endDate': $('#endDate').val(),
                'dateFormat': 'month'
            }
            var nowDate = new Date();
            var timeStr = nowDate.toISOString().substr(0, 7);
            $('.yearMonthClick').val(timeStr);
            $('.yearMonthClickEnd').val(timeStr);
            $scope.searchData.startDate = timeStr;
            $scope.searchData.endDate = timeStr;
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('settlementRep/query', $scope.searchData, function (data) {
                    $scope.result = data.data.recordList;
                    $scope.smNumsCount = data.data.smNumsCount;
                    $scope.sendSucCount = data.data.sendSucCount;
                    $scope.recvFailCount = data.data.recvFailCount;
                    $scope.recvNoneCount = data.data.recvNoneCount;
                    $scope.recvSucCount = data.data.recvSucCount;
                    $scope.upTotalCount = data.data.upTotalCount;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }

                });
            }
            $scope.upData();


            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                //        $scope.searchData.dateFormat = 'month';
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function () {
                $scope.searchData.startDate = $('#startDate').val();
                $scope.searchData.endDate = $('#endDate').val();
                $scope.upData();
            }
            //启用时间插件
            // MyFactory.DateTimePicker($scope, '.form_datetime', 'yyyy-mm', 4, 3, 'startDate')
            // MyFactory.DateTimePicker($scope, '.form_datetime1', 'yyyy-mm', 4, 3, 'endDate')


            //初始化当前时间
            var date = new Date;
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            if (month < 10) {
                month = '0' + month;
            }

            //-------起始月期--------
            $('.yearValue').text(year)
            for (var i = 0; i < 12; i++) {
                if ($('.monthBox>li').eq(i).text() == month) {
                    $('.monthBox>li').eq(i).addClass('monthClick')
                }
            }

            $('.YearMonth').val(year + '-' + month);


            //点击弹出选择框
            $('.yearMonthClick').click(function () {
                if ($('.selectYearMonths').hasClass('date_picker')) {
                    $('.selectYearMonths').removeClass('date_picker')
                } else {
                    $('.selectYearMonths').addClass('date_picker')
                }
            })
            //点击左箭头，起始年份减1
            $('.subYear').click(function () {
                var yearValue = $('.yearValue').text();
                yearValue--;
                $('.yearValue').text(yearValue);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthBox>li').eq(i).hasClass('monthClick')) {
                        $('.YearMonth').val(yearValue + '-' + $('.monthFromBox>li').eq(i).text())
                    }
                }
            })
            //点击右箭头，起始年份加1
            $('.addYear').click(function () {
                var yearValue = +$('.yearValue').text();
                yearValue++;
                $('.yearValue').text(yearValue);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthBox>li').eq(i).hasClass('monthClick')) {
                        $('.YearMonth').val(yearValue + '-' + $('.monthBox>li').eq(i).text())
                    }
                }
            })
            //起始月份，移入改变样式
            $(".monthFromBox>li").mouseover(function () {
                $(this).addClass('monthActive').siblings().removeClass('monthActive');
            });
            //移出月份框,保留点击样式,移除mouseover样式
            $(".monthFromBox").mouseout(function () {
                $(".monthBox>li").removeClass('monthActive');
            });
            //点击第一个选框里的月份
            $(".monthBox>li").click(function () {
                $('.YearMonth').val($('.yearValue').text() + '-' + $(this).text())
                $(this).addClass('monthClick').siblings().removeClass('monthClick')

            });
            //点击取消，关闭弹框
            $(".closeBtn").click(function () {
                $('.selectYearMonths').addClass('date_picker')
            });
            //点击確定，关闭弹框,改变值
            $(".okBtn").click(function () {
                $('.selectYearMonths').addClass('date_picker')
                $('.yearMonthClick').val($('.YearMonth').val())
                $scope.searchData.startDate = $('.yearMonthClick').val().substr(0, 7);
            });
            $scope.searchData.startDate = $('.yearMonthClick').val().substr(0, 7);
            //-------起始月期结束--------

            //-------结束月期--------
            $('.yearValueEnd').text(year)
            for (var i = 0; i < 12; i++) {
                if ($('.monthBoxEnd>li').eq(i).text() == month) {
                    $('.monthBoxEnd>li').eq(i).addClass('monthClickEnd')
                }
            }

            $('.YearMonthEnd').val(year + '-' + month);


            //点击弹出选择框
            $('.yearMonthClickEnd').click(function () {
                if ($('.selectYearMonthsEnd').hasClass('date_pickerEnd')) {
                    $('.selectYearMonthsEnd').removeClass('date_pickerEnd')
                } else {
                    $('.selectYearMonthsEnd').addClass('date_pickerEnd')
                }
            })
            //点击左箭头，起始年份减1
            $('.subYearEnd').click(function () {
                var yearValue = $('.yearValueEnd').text();
                yearValue--;
                $('.yearValueEnd').text(yearValue);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthBoxEnd>li').eq(i).hasClass('monthClickEnd')) {
                        $('.YearMonthEnd').val(yearValue + '-' + $('.monthFromBoxEnd>li').eq(i).text())
                    }
                }
            })
            //点击右箭头，起始年份加1
            $('.addYearEnd').click(function () {
                var yearValueEnd = +$('.yearValueEnd').text();
                yearValueEnd++;
                $('.yearValueEnd').text(yearValueEnd);
                for (var i = 0; i < 12; i++) {
                    if ($('.monthBoxEnd>li').eq(i).hasClass('monthClickEnd')) {
                        $('.YearMonthEnd').val(yearValue + '-' + $('.monthBoxEnd>li').eq(i).text())
                    }
                }
            })
            //起始月份，移入改变样式
            $(".monthFromBoxEnd>li").mouseover(function () {
                $(this).addClass('monthActiveEnd').siblings().removeClass('monthActiveEnd');
            });
            //移出月份框,保留点击样式,移除mouseover样式
            $(".monthFromBoxEnd").mouseout(function () {
                $(".monthBoxEnd>li").removeClass('monthActiveEnd');
            });
            //点击第一个选框里的月份
            $(".monthBoxEnd>li").click(function () {
                $('.YearMonthEnd').val($('.yearValueEnd').text() + '-' + $(this).text())
                $(this).addClass('monthClickEnd').siblings().removeClass('monthClickEnd')

            });
            //点击取消，关闭弹框
            $(".closeBtnEnd").click(function () {
                $('.selectYearMonthsEnd').addClass('date_pickerEnd')
            });
            //点击確定，关闭弹框,改变值
            $(".okBtnEnd").click(function () {
                $('.selectYearMonthsEnd').addClass('date_pickerEnd')
                $('.yearMonthClickEnd').val($('.YearMonthEnd').val())
                $scope.searchData.endDate = $('.yearMonthClickEnd').val().substr(0, 7);
            });
            $scope.searchData.endDate = $('.yearMonthClickEnd').val().substr(0, 7);
            //-------结束月期结束--------


            $scope.clearStart = function () {
                $scope.searchData.startDate = ''
            };
            $scope.clearEnd = function () {
                $scope.searchData.endDate = ''
            };

            //下钻
            //下发短信明细
            $scope.GoDsDetail = function (tTime, eTime, recvSuc, recvFail, recvNone, gateLinkId) {
                var obj = {
                    'tTime': tTime,
                    'eTime': eTime,
                    'recvSuc': recvSuc,
                    'recvFail': recvFail,
                    'recvNone': recvNone,
                    'gateLinkId': gateLinkId,
                }
                var str = JSON.stringify(obj);
                localStorage.setItem('MtoDs', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-dsSmsDetails').css('color', '#fff');
                location.href = '#/dsSmsDetails';
            }
            //上行短信明细
            $scope.GoUpDetail = function (tTime, eTime, upTotal, gateLinkId) {
                var obj = {
                    'tTime': tTime,
                    'eTime': eTime,
                    'gateLinkId': gateLinkId
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('MtoUp', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-upSmsStatistics').css('color', '#fff');
                location.href = '#/upSmsStatistics';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})
//========结算年报表==========//
app.controller('settlementStatementY', function ($scope, $timeout, MyFactory) {
    MyFactory.GetAjaxs('users/authentication', 'settlementStatementY', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'dateFormat': 'year'
            }
            var nowDate = new Date();
            var timeStr = nowDate.toISOString().substr(0, 4);
            $scope.searchData.startDate = timeStr;
            $scope.searchData.endDate = timeStr;
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('settlementRep/query', $scope.searchData, function (data) {
                    $scope.result = data.data.recordList;
                    $scope.smNumsCount = data.data.smNumsCount;
                    $scope.sendSucCount = data.data.sendSucCount;
                    $scope.recvFailCount = data.data.recvFailCount;
                    $scope.recvNoneCount = data.data.recvNoneCount;
                    $scope.recvSucCount = data.data.recvSucCount;
                    $scope.upTotalCount = data.data.upTotalCount;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }

                });
            }
            $scope.upData();
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                //        $scope.searchData.dateFormat = 'year';
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function () {
                $scope.searchData.startDate = $('#startDate').val()
                $scope.searchData.endDate = $('#endDate').val();
                $scope.upData();
            }
            //启用时间插件
            MyFactory.DateTimePicker($scope, '.form_datetime', 'yyyy', 4, 4, 'startDate')
            MyFactory.DateTimePicker($scope, '.form_datetime1', 'yyyy', 4, 4, 'endDate')
            $scope.clearStart = function () {
                $scope.searchData.startDate = ''
            };
            $scope.clearEnd = function () {
                $scope.searchData.endDate = ''
            };

            //下钻
            //下发短信明细
            $scope.GoDsDetail = function (tTime, eTime, recvSuc, recvFail, recvNone, gateLinkId) {
                var obj = {
                    'tTime': tTime,
                    'eTime': eTime,
                    'recvSuc': recvSuc,
                    'recvFail': recvFail,
                    'recvNone': recvNone,
                    'gateLinkId': gateLinkId
                }
                var str = JSON.stringify(obj);
                localStorage.setItem('YtoDs', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-dsSmsDetails').css('color', '#fff');
                location.href = '#/dsSmsDetails';
            }
            //上行短信明细
            $scope.GoUpDetail = function (tTime, eTime, upTotal, gateLinkId) {
                var obj = {
                    'tTime': tTime,
                    'eTime': eTime,
                    'gateLinkId': gateLinkId
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('YtoUp', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-upSmsStatistics').css('color', '#fff');
                location.href = '#/upSmsStatistics';
            }
        } else {

            location.href = '#/forbid';
        }
    });
});

// ==========短信递交失败分析 业务端系统========== //
app.controller('smsSubmitFail', function ($scope, appService, $timeout, MyFactory) {
    MyFactory.GetAjaxs('users/authentication', 'smsSubmitFail', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'svrNodes': ''
            }

            // 时间插件
            MyFactory.Date($scope, '#smsSubmitFail', 'startDate', 'endDate');

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/smSubmitFail/querySvrCount', $scope.searchData, function (data) {
                    $scope.result = data.allCount.result;
                    $scope.dayCount = data.dayCount;
                    $scope.svrCount = data.svrCount;
                    $scope.selPage = data.allCount.pageNo;
                    $scope.count = data.allCount.totalCount;
                    $scope.totalCount = data.allCount.totalPages;
                    $scope.loaded = false;
                    // 定义数组接受数据
                    $scope.smsData = [];
                    $scope.sysData = [];
                    $scope.tysData = [];
                    $scope.mmsData = [];
                    for (var i = 0; i < $scope.svrCount.length; i++) {
                        var obj = {}
                        var obs = {}
                        obj.value = $scope.svrCount[i].svrCounts;
                        obj.name = $scope.svrCount[i].svrName;
                        obs = $scope.svrCount[i].svrName;
                        $scope.smsData.push(obj);
                        $scope.sysData.push(obs);
                    }
                    // 饼图
                    var myChart = echarts.init(document.getElementById('system'));
                    var options = {
                        title: {
                            text: '按时间划分每个业务端数据比例',
                            x: 'center',
                            textStyle: {
                                fontSize: 16,
                            }
                        },
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} ({d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            right: 100,
                            top: 50,
                            bottom: 20,
                            data: $scope.sysData
                        },
                        series: [{
                            name: '访问来源',
                            type: 'pie',
                            radius: '55%',
                            center: ['30%', '50%'],
                            data: $scope.smsData,
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }]
                    }
                    myChart.setOption(options);

                    // 失败量统计图
                    for (var i = 0; i < $scope.dayCount.length; i++) {
                        $scope.tysData.push($scope.dayCount[i].day);
                        $scope.mmsData.push($scope.dayCount[i].dayCounts);
                    }
                    App.shapeChart('fail', $scope.tysData, $scope.mmsData, '每日所有业务端递交失败总数')

                    function everyClick(param, i, txt, url) { //程序这边的url需要传入
                        if (param.seriesIndex == 0 && param.dataIndex == i) {
                            location.href = url;
                            for (var i = 0; i < $scope.listData1.length; i++) {
                                if (txt == $scope.listData1[i].SVR_NODE_NAME) {
                                    txt = $scope.listData1[i].SVR_NODE;
                                }
                            }
                            appService.svrNode = txt;
                            appService.startDate = $scope.searchData.startDate;
                            appService.endDate = $scope.searchData.endDate;
                        }
                    }
                    //增加监听事件
                    function eConsole(param) {
                        if (typeof param.seriesIndex != 'undefined') {
                            if (param.type == 'click') {
                                var peiLenght = options.legend.data.length;
                                // 获取总共给分隔的扇形数
                                for (var i = 0; i < peiLenght; i++) {
                                    everyClick(param, i, options.legend.data[i], '#/smsSubmitFailType')
                                }
                            }

                        }
                    }
                    myChart.on("click", eConsole);

                    // 回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/smSubmitFail/querySvrCount', $scope.searchData, function (data) {
                        $scope.result = data.allCount.result;
                    })

                });

            }

            $scope.upData();
            //页数选择及显示条数
            MyFactory.selectPage($scope);
            $scope.listData2 = [];
            //下拉数据加载
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
                for (var i = 0; i < data.length; i++) {
                    $scope.listData2.push(data[i].SVR_NODE_NAME);
                }
                $timeout(function () {
                    $('#svrNodes').fSelect();
                    $('.fs-wrap').css("marginLeft", "44px");
                }, 50);
            });

            //时间调用
            $('#smsSubmitFail').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsSubmitFail").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(13));

            });

            //查询
            $scope.search = function (e) {
                var svrNodes = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#smsSubmitFail").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(13);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            svrNodes.push($(this).attr("data-value"));
                        })
                        $scope.searchData.svrNodes = svrNodes.toString();
                        $scope.upData();
                    }

                } else {
                    var strData = $("#smsSubmitFail").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(13);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        svrNodes.push($(this).attr("data-value"));
                    })
                    $scope.searchData.svrNodes = svrNodes.toString();
                    $scope.upData();
                }
            }
            // 导出表格
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });

});

// ==========短信递交失败分析 详情========== //
app.controller('smsSubmitFailType', function ($scope, appService, $timeout, MyFactory) {
    MyFactory.GetAjaxs('users/authentication', 'smsSubmitFailType', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'svrNodes': ''
            }
            // 时间插件
            MyFactory.Date($scope, '#smsSubmitFailType', 'startDate', 'endDate');

            // 判断是否传值
            if (appService.svrNode || appService.startDate || appService.endDate) {
                $scope.searchData.svrNodes = appService.svrNode;
                $scope.searchData.startDate = appService.startDate;
                $scope.searchData.endDate = appService.endDate;
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/smSubmitFail/querySvrDetail', $scope.searchData, function (data) {
                    $scope.result = data.allDetail.result;
                    $scope.svrDetail = data.svrDetail;
                    $scope.selPage = data.allDetail.pageNo;
                    $scope.count = data.allDetail.totalCount;
                    $scope.totalCount = data.allDetail.totalPages;
                    $scope.loaded = false;

                    // 定义数据接受图形数据
                    $scope.asaData = [];
                    $scope.msmData = [];
                    for (var i = 0; i < $scope.svrDetail.length; i++) {
                        var obj = {}
                        var num = {}
                        obj.value = $scope.svrDetail[i].count;
                        obj.name = $scope.svrDetail[i].sendCode;
                        num = $scope.svrDetail[i].sendCode;
                        $scope.asaData.push(obj);
                        $scope.msmData.push(num);
                    }

                    // 系统饼图
                    App.roundChart('type', $scope.msmData, $scope.asaData, '按时间划分单个系统数据总和');

                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/smSubmitFail/querySvrDetail', $scope.searchData, function (data) {
                        $scope.result = data.allDetail.result;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //下拉数据加载
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
                $timeout(function () {
                    $('#svrNodes').fSelect();
                    $('.fs-wrap').css("marginLeft", "44px");
                }, 50);
            });

            //时间调用
            $('#smsSubmitFailType').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsSubmitFailType").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(13));

            });

            //查询
            $scope.search = function (e) {
                var svrNodes = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#smsSubmitFailType").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(13);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            svrNodes.push($(this).attr("data-value"));
                        })
                        $scope.searchData.svrNodes = svrNodes.toString();
                        $scope.upData();
                    }

                } else {
                    var strData = $("#smsSubmitFailType").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(13);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        svrNodes.push($(this).attr("data-value"));
                    })
                    $scope.searchData.svrNodes = svrNodes.toString();
                    $scope.upData();
                }
            }
            // 导出表格
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });

});

// ==========短信递交失败分析 通道端通道========== //
app.controller('smsSubmitFailPass', function ($scope, appService, $timeout, MyFactory) {
    MyFactory.GetAjaxs('users/authentication', 'smsSubmitFailPass', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'gateLinkIds': ''
            }

            MyFactory.Date($scope, '#smsSubmitFailPass', 'startDate', 'endDate');

            // 数据
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/smSubmitFail/queryGateCount', $scope.searchData, function (data) {
                    $scope.result = data.gateAllCount.result;
                    $scope.gateDayCount = data.gateDayCount;
                    $scope.gateCount = data.gateCount;
                    $scope.selPage = data.gateAllCount.pageNo;
                    $scope.count = data.gateAllCount.totalCount;
                    $scope.totalCount = data.gateAllCount.totalPages;
                    $scope.loaded = false;
                    // 定义数组接受图形数据
                    $scope.smsData = [];
                    $scope.sysData = [];
                    $scope.tysData = [];
                    $scope.mmsData = [];
                    for (var i = 0; i < $scope.gateCount.length; i++) {
                        var obj = {}
                        var obs = {}
                        obj.value = $scope.gateCount[i].counts;
                        obj.name = $scope.gateCount[i].gateLinkName;
                        obs = $scope.gateCount[i].gateLinkName;
                        $scope.smsData.push(obj);
                        $scope.sysData.push(obs);
                    }

                    // 饼图
                    var myChart = echarts.init(document.getElementById('PassSystem'));
                    var options = {
                        title: {
                            text: '按时间划分每个通道数据总和',
                            x: 'center'
                        },
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} ({d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            right: 100,
                            top: 50,
                            bottom: 20,
                            data: $scope.sysData
                        },
                        series: [{
                            name: '访问来源',
                            type: 'pie',
                            radius: '55%',
                            center: ['30%', '50%'],
                            data: $scope.smsData,
                            itemStyle: {
                                emphasis: {
                                    shadowBlur: 10,
                                    shadowOffsetX: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                                }
                            }
                        }]
                    }
                    myChart.setOption(options);
                    // 失败量统计图
                    for (var i = 0; i < $scope.gateDayCount.length; i++) {
                        $scope.tysData.push($scope.gateDayCount[i].day);
                        $scope.mmsData.push($scope.gateDayCount[i].counts);
                    }
                    App.shapeChart('PassFail', $scope.tysData, $scope.mmsData, '每日所有通道递交失败总数')

                    function everyClick(param, i, txt, url) { //程序这边的url需要传入
                        if (param.seriesIndex == 0 && param.dataIndex == i) {
                            location.href = url;
                            for (var i = 0; i < $scope.listData2.length; i++) {
                                if (txt == $scope.listData2[i].GATE_LINK_NAME) {
                                    txt = $scope.listData2[i].GATE_LINK_ID;
                                }
                            }
                            appService.start = $scope.searchData.startDate;
                            appService.end = $scope.searchData.endDate;
                            appService.gateLinkIds = txt;
                        }
                    }
                    //增加监听事件
                    function eConsole(param) {
                        if (typeof param.seriesIndex != 'undefined') {
                            if (param.type == 'click') {
                                var peiLenght = options.legend.data.length;
                                // 获取总共给分隔的扇形数
                                for (var i = 0; i < peiLenght; i++) {
                                    everyClick(param, i, options.legend.data[i], '#/smsSubmitFailPassType')
                                }
                            }

                        }
                    }
                    myChart.on("click", eConsole);
                    // 回调
                    if (callback) {
                        callback();
                    }

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/smSubmitFail/queryGateCount', $scope.searchData, function (data) {
                        $scope.result = data.gateAllCount.result;
                    })

                });

            }

            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                $scope.listData2 = data;
                $timeout(function () {
                    $('#gateLinkId').fSelect();
                    $('.fs-wrap').css("marginLeft", "56px");
                }, 50);
            });
            //时间调用
            $('#smsSubmitFailPass').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsSubmitFailPass").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(13));

            });

            //查询
            $scope.search = function (e) {
                var gateLinkIds = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#smsSubmitFailPass").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(13);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            gateLinkIds.push($(this).attr("data-value"));
                        })
                        $scope.searchData.gateLinkIds = gateLinkIds.toString();
                        $scope.upData();
                    }

                } else {
                    var strData = $("#smsSubmitFailPass").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(13);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        gateLinkIds.push($(this).attr("data-value"));
                    })
                    $scope.searchData.gateLinkIds = gateLinkIds.toString();
                    $scope.upData();
                }
            }
            // 导出表格
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });

});

// ==========短信递交失败分析 通道端详情========== //
app.controller('smsSubmitFailPassType', function ($scope, appService, $timeout, MyFactory) {
    MyFactory.GetAjaxs('users/authentication', 'smsSubmitFailPassType', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'gateLinkIds': ''
            }
            // 时间插件
            MyFactory.Date($scope, '#smsSubmitFailPassType', 'startDate', 'endDate');

            // 判断是否传值
            if (appService.gateLinkIds || appService.start || appService.end) {
                $scope.searchData.gateLinkIds = appService.gateLinkIds;
                $scope.searchData.startDate = appService.start;
                $scope.searchData.endDate = appService.end;
            }


            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/smSubmitFail/queryGateDetail', $scope.searchData, function (data) {
                    $scope.result = data.gateAllDetail.result;
                    $scope.gateDetail = data.gateDetail;
                    $scope.selPage = data.gateAllDetail.pageNo;
                    $scope.count = data.gateAllDetail.totalCount;
                    $scope.totalCount = data.gateAllDetail.totalPages;
                    $scope.loaded = false;

                    // 定义数组接受图形数据
                    $scope.asaData = [];
                    $scope.msmData = [];
                    for (var i = 0; i < $scope.gateDetail.length; i++) {
                        var obj = {}
                        var num = {}
                        obj.value = $scope.gateDetail[i].count;
                        obj.name = $scope.gateDetail[i].sendCode;
                        num = $scope.gateDetail[i].sendCode;
                        $scope.asaData.push(obj);
                        $scope.msmData.push(num);
                    }
                    // 系统饼图
                    App.roundChart('PassType', $scope.msmData, $scope.asaData, '按时间划分单个通道数据总和');
                    //回调
                    if (callback) {
                        callback();
                    }

                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/smSubmitFail/queryGateDetail', $scope.searchData, function (data) {
                        $scope.result = data.gateAllDetail.result;
                    })

                });
            }
            $scope.upData();

            MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                $scope.listData2 = data;
                $timeout(function () {
                    $('#gateLinkId').fSelect();
                    $('.fs-wrap').css("marginLeft", "56px");
                }, 50);
            });

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //时间调用
            $('#smsSubmitFailPassType').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsSubmitFailPassType").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(13));

            });

            //查询
            $scope.search = function (e) {
                var gateLinkIds = [];
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#smsSubmitFailPassType").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(13);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $('.selected').each(function () {
                            gateLinkIds.push($(this).attr("data-value"));
                        })
                        $scope.searchData.gateLinkIds = gateLinkIds.toString();
                        $scope.upData();
                    }

                } else {
                    var strData = $("#smsSubmitFailPassType").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(13);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $('.selected').each(function () {
                        gateLinkIds.push($(this).attr("data-value"));
                    })
                    $scope.searchData.gateLinkIds = gateLinkIds.toString();
                    $scope.upData();
                }
            }

            // 导出表格
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
        } else {

            location.href = '#/forbid';
        }
    });

});

// ==========短信拨测模板========== //
app.controller('smsDialing', function ($scope, $http, MyFactory) {
    MyFactory.GetAjaxs('users/authentication', 'smsDialing', function (data) {
        if (data.data.isSuccess) {
            $scope.Tips = false;
            $scope.addData = {
                'testContent': '',
                'sendTime': '',
                'remark': '',
                'recId': ''
            }
            $scope.init = function () {
                MyFactory.PostAjax('/smCallTest/query', '', function (data) {
                    $scope.addData.testContent = data.result[0].testContent;
                    $scope.addData.sendTime = data.result[0].sendTime;
                    $scope.addData.remark = data.result[0].remark;
                    $scope.addData.recId = data.result[0].recId;
                })
            }
            $scope.init();
            $scope.optimAll1 = function () {
                $scope.addData.testContent = $scope.addData.testContent + '[gateLinkId]';
            }
            $scope.optimAll2 = function () {
                $scope.addData.testContent = $scope.addData.testContent + '[time]';
            }
            $scope.optimAll3 = function () {
                $scope.addData.testContent = $scope.addData.testContent + '[userNum]';
            }
            $scope.editSaves = function () {
                //信息无误开始请求
                if (60 % $scope.addData.sendTime == 0) {
                    $scope.Tips = false;
                    MyFactory.PostAjax('/smCallTest/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            App.alert(data.msg, function () { });
                            $scope.init();
                        } else {
                            App.alert(data.msg)
                        }
                    })

                } else {
                    // $scope.onData.Tips = '*请输入能被60除尽的数，例如：1，2，3，~30，60';
                    // alert('请输入能被60除尽的数，例如：1，2，3，~30，60');
                    $scope.Tips = true;
                }
            }
        } else {
            location.href = '#/forbid';
        }
    });
});

// ==========短信拨测通道========== //
app.controller('smsDialingPass', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsDialingPass', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'status': ''
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/callTestGate/getTestGate', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                });
            };
            $scope.upData();

            $scope.addData = {
                'gateLinkId': '',
                'gateLinkName': ''
            }

            //通道下拉列表
            MyFactory.PostAjax('/gateDef/getGateLink', {}, function (data) {
                $scope.listData2 = data;
            })

            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/callTestGate/toUpdate', {
                        'recId': code
                    }, function (data) {
                        $scope.addData.gateLinkId = data.gateLinkId;
                        $scope.addData.gateLinkName = data.gateLinkName;
                    })
                } else {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'gateLinkId': ''
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    /*MyFactory.PostAjax('/callTestGate/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })*/
                } else {
                    MyFactory.PostAjax('callTestGate/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.code = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/callTestGate/delete', {
                    'recId': $scope.code
                }, function (data) {
                    if (data.isSuccess == true) {
                        App.alert(data.msg);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });
});

// ==========短信拨测号码========== //
app.controller('smsDialingNum', function ($scope, $http, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsDialingNum', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'testPhone': '',
                'username': ''
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/callTestPhone/getTestPhone', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                });
            };
            $scope.upData();

            $scope.search = function () {
                $scope.upData();
            }

            $scope.addData = {
                'testPhone': '',
                'username': '',
                'status': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/callTestPhone/toUpdate', {
                        'recId': code
                    }, function (data) {
                        $scope.addData.testPhone = data.testPhone;
                        $scope.addData.username = data.username;
                        $scope.addData.status = data.status;
                        $scope.addData.recId = data.recId;
                    })
                } else {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'testPhone': '',
                        'username': '',
                        'status': ''
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {

                //手机号码的验证
                var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                if (!myreg.test($("#phone").val())) {
                    App.alert('请输入有效的手机号码！');
                    return false;
                }
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('/callTestPhone/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('callTestPhone/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.code = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/callTestPhone/delete', {
                    'recId': $scope.code
                }, function (data) {
                    if (data.isSuccess == true) {
                        App.alert(data.msg);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });
});

// ==========短信生命周期监控========== //
app.controller('smsLifeCycle', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsLifeCycle', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'startDate': '',
                'endDate': '',
                'userNo': ''
            }

            MyFactory.Date($scope, '#smsLifeCycle', 'startDate', 'endDate');

            $scope.upData = function (callback) {
                var end = $scope.searchData.endDate;
                var start = $scope.searchData.startDate;

                function getTime2Time($time1, $time2) {
                    var time1 = arguments[0],
                        time2 = arguments[1];
                    time1 = Date.parse(time1) / 1000;
                    time2 = Date.parse(time2) / 1000;
                    var time_ = time1 - time2;
                    return (time_ / (3600 * 24));
                }
                var days = getTime2Time(end, start);
                if (days > 31) {
                    App.alert('一次查询时间范围不能超过31天！');
                } else {
                    $scope.loaded = true;
                    MyFactory.PostAjax('/sendSmLife/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }

                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/sendSmLife/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })
                    });
                }

            };

//            $scope.upData();
            MyFactory.selectPage($scope);

            //查询
            $scope.errors = ''
            $scope.search = function () {
                var strData = $("#smsLifeCycle").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                $scope.searchData.pageNo = 1;
                if ((/^1[34578]\d{9}$/.test($scope.searchData.userNo))) {
                    $scope.errors = ''
                    $scope.upData();
                } else {
                    $scope.errors = '请输入有效手机号';
                }
            }


            //时间调用
            $('#smsLifeCycle').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsLifeCycle").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));
            });

            $scope.editTr = function (recId) {
                var Ids = recId;
                for (var i = 0; i < $scope.result.length; i++) {
                    if ($scope.result[i].recId == Ids) {
                        $scope.timeData = $scope.result[i];

                        if ($scope.timeData.recvTime != '') {
                            $('#sqImg').attr('src', '../../img/1sqs.png');
                        } else {
                            $('#sqImg').attr('src', '../../img/1sq.png');
                        }
                        if ($scope.timeData.recvTimeTime != '') {
                            $('#xqImg').attr('src', '../../img/1xqs.png');
                        } else {
                            $('#xqImg').attr('src', '../../img/1xq.png');
                        }
                        if ($scope.timeData.sendTime != '') {
                            $('#zqImg').attr('src', '../../img/2zqs.png');
                        } else {
                            $('#zqImg').attr('src', '../../img/2zq.png');
                        }
                        if ($scope.timeData.sendTimeTime != '') {
                            $('#yqImg').attr('src', '../../img/2yqs.png');
                        } else {
                            $('#yqImg').attr('src', '../../img/2yq.png');
                        }
                        if ($scope.timeData.recvReportTime != '') {
                            $('#sqImg1').attr('src', '../../img/3sqs.png');
                        } else {
                            $('#sqImg1').attr('src', '../../img/3sq.png');
                        }
                        if ($scope.timeData.recvReportTimeTime != '') {
                            $('#xqImg1').attr('src', '../../img/3xqs.png');
                        } else {
                            $('#xqImg1').attr('src', '../../img/3xq.png');
                        }
                    }
                }
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//========运营分析工作台结束==========//

//========短信发送统计==========//
app.controller('sendStat', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'sendStat', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.setSms($scope);

            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
                'startDate': '',
                'endDate': '',
            }
            MyFactory.Date($scope, '#sendStatDate', 'startDate', 'endDate');

            //默认查询前一天
            var nowDate = new Date(new Date().getTime() - 86400000);
            var timeStr = nowDate.toISOString().substr(0, 10);
            App.d('#sendStatDate').value = timeStr + ' - ' + timeStr;
            $scope.searchData['startDate'] = timeStr;
            $scope.searchData['endDate'] = timeStr;
            $scope.upData = function (callback) {
                $scope.loaded = true;

                MyFactory.PostAjax('smFlow/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'smFlow/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();

            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };

            //查询
            $scope.search = function () {
                var strData = $("#sendStatDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }


            //时间调用
            $('#sendStatDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#sendStatDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });



            //下钻下发短信明细
            $scope.GoDsDetail = function (tTime, sendSuc, sendFail, recvSuc, recvFail, recvNone, svrNode, serviceCode) {
                var obj = {
                    'tTime': tTime,
                    'sendSuc': sendSuc,
                    'sendFail': sendFail,
                    'recvSuc': recvSuc,
                    'recvFail': recvFail,
                    'recvNone': recvNone,
                    'svrNode': svrNode,
                    'serviceCode': serviceCode
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('sendStatToDs', str);
                //改变导航栏高亮
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-sendDetail').css('color', '#fff');
                location.href = '#/sendDetail';
            }
            //下钻上行短信明细
            $scope.GoUpDetail = function (tTime, svrNode) {
                var obj = {
                    'tTime': tTime,
                    'svrNode': svrNode
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('sendStatToUp', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-recieveDetail').css('color', '#fff');
                location.href = '#/recieveDetail';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//========短信模板设置==========//
app.controller('smsTemplate', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsTemplate', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
                'smTemplet': '',
                'startDate': '',
                'endDate': ''
            }
            // 时间初始化
            MyFactory.Date($scope, '#smsTemplateDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/smModule/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/smModule/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();

            //页数选择及显示条数
            MyFactory.selectPage($scope);

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('/smModule/changeStatus', {
                    'smTempletId': code,
                    'status': status
                }, function (data) {
                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '生效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            };

            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            })
            //短信类型下拉列表
            MyFactory.PostAjax('/serviceCodeDef/getAll', {}, function (data) {
                $scope.listData2 = data;
            })
            //时间调用
            $('#smsTemplateDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#smsTemplateDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });

            //查询
            $scope.search = function (e) {

                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        var strData = $("#smsTemplateDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.select_all = false;
                        $scope.upData();
                    }

                } else {
                    var strData = $("#smsTemplateDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.select_all = false;
                    $scope.upData();
                }

            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'svrNode': '',
                'serviceCode': '',
                'smTemplet': '',
                'status': '',
                'remark': ''
            }

            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/smModule/toUpdate', {
                        'smTempletId': code
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode);
                        $scope.addData.svrNode = data.svrNode;
                        $scope.addData.serviceCode = data.serviceCode;
                        $scope.addData.smTemplet = data.smTemplet;
                        $scope.addData.status = data.status;
                        $scope.addData.remark = data.remark;
                        $scope.addData.smTempletId = data.smTempletId;
                    })
                } else {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'svrNode': $scope.listData1[0].SVR_NODE,
                        'serviceCode': $scope.listData2[0].serviceCode,
                        'smTemplet': '',
                        'status': '',
                        'remark': ''
                    }
                    $scope.varAll($scope.addData.svrNode);
                }
            }
            // 查询变量
            MyFactory.PostAjax('/smModuleVar/getAllVar', {}, function (data) {
                $scope.listData3 = data;
            });

            // 通过业务端查询变量
            $scope.varAll = function (value) {
                MyFactory.PostAjax('/smModuleVar/getVarBySvrAndCom', {
                    'svrNode': value
                }, function (data) {
                    $scope.listData3 = data;
                });
            }

            // 模板添加变量
            $scope.optimAll = function (e) {
                $scope.addData.smTemplet = $scope.addData.smTemplet + e;
            }

            //添加和修改数据
            $scope.editSave = function () {
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('/smModule/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('/smModule/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.code = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/smModule/delete', {
                    'smTempletId': $scope.code
                }, function (data) {
                    if (data.isSuccess == true) {
                        App.alert(data.msg);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//========短信模板变量设置==========//
app.controller('smsTemplateVar', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'smsTemplateVar', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'svrNode': ''
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/smModuleVar/getVarBySet', $scope.searchData, function (data) {
                    $scope.result = data;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }

                });
            }
            $scope.upData();

            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData1 = data;
            })

            $scope.search = function (e) {

                if (e) {
                    var keycode = window.event ? e.keyCode : e.which; //获取按键编码
                    if (keycode == 13) {
                        $scope.select_all = false;
                        $scope.upData();
                    }

                } else {
                    $scope.select_all = false;
                    $scope.upData();
                }

            }

            $scope.edirPo = function (svr) {
                var svr = svr;
                $scope.lists = $scope.result[svr];
            }

            //添加或者编辑挂载数据
            $scope.addData = {
                'svrNode': '',
                'moVar': '',
                'remark': '',
                'moContent': ''
            }
            $scope.editTr = function (str, code) {
                $scope.popup = str;
                if (str == '修改') {
                    $scope.isDisabled = true;
                    MyFactory.PostAjax('/smModuleVar/toUpdate', {
                        'recId': code
                    }, function (data) {
                        $scope.addData.svrNode = data.svrNode;
                        $scope.addData.moVar = data.moVar;
                        $scope.addData.remark = data.remark;
                        $scope.addData.moContent = data.moContent;
                        $scope.addData.recId = data.recId;
                    })
                } else {
                    $scope.isDisabled = false;
                    $scope.addData = {
                        'svrNode': '',
                        'moVar': '',
                        'remark': '',
                        'moContent': ''
                    }
                }
            }

            //添加和修改数据
            $scope.editSave = function () {
                //信息无误开始请求
                if ($scope.popup == '修改') {
                    MyFactory.PostAjax('/smModuleVar/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                } else {
                    MyFactory.PostAjax('/smModuleVar/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#add').modal('hide');
                            });
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //删除信息
            $scope.delete = function (code) {
                $scope.code = code;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/smModuleVar/delete', {
                    'recId': $scope.code
                }, function (data) {
                    if (data.isSuccess == true) {
                        App.alert(data.msg);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//=============短信发送统计 接收短信=================//
app.controller('reserveStat', function ($scope, $timeout, $http, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'reserveStat', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.setSms($scope);

            $scope.searchData = {
                'svrNode': '',
                'serviceCode': '',
                'startDate': '',
                'endDate': '',
            }
            MyFactory.Date($scope, '#reserveStatDate', 'startDate', 'endDate');

            //默认查询前一天
            var nowDate = new Date(new Date().getTime() - 86400000);
            var timeStr = nowDate.toISOString().substr(0, 10);
            App.d('#reserveStatDate').value = timeStr + ' - ' + timeStr;
            $scope.searchData['startDate'] = timeStr;
            $scope.searchData['endDate'] = timeStr;
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('smFlow/queryUp', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'smFlow/queryUp', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();



            MyFactory.selectPage($scope);

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };

            //查询
            $scope.search = function () {
                var strData = $("#reserveStatDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }


            //时间调用
            $('#reserveStatDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#reserveStatDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });



            //下钻下发短信明细
            $scope.GoDsDetail = function (tTime, sendSuc, sendFail, recvSuc, recvFail, recvNone, svrNode, serviceCode) {
                var obj = {
                    'tTime': tTime,
                    'sendSuc': sendSuc,
                    'sendFail': sendFail,
                    'recvSuc': recvSuc,
                    'recvFail': recvFail,
                    'recvNone': recvNone,
                    'svrNode': svrNode,
                    'serviceCode': serviceCode
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('sendStatToDs', str);
                //改变导航栏高亮
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-sendDetail').css('color', '#fff');
                location.href = '#/sendDetail';
            }
            //下钻上行短信明细
            $scope.GoUpDetail = function (tTime, svrNode) {
                var obj = {
                    'tTime': tTime,
                    'svrNode': svrNode
                };
                var str = JSON.stringify(obj);
                localStorage.setItem('sendStatToUp', str);
                $('.site-menu-item a').css('color', 'rgba(163,175,183,.9)');
                $('.nav-recieveDetail').css('color', '#fff');
                location.href = '#/recieveDetail';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})

//========短信发送明细==========//
app.controller('sendDetail', function ($scope, $timeout, $filter, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'sendDetail', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                'limitCount': '10000',
                'sendCode': '',
                'resultCode': '',
                'svrNode': '',
                'serviceCode': '',
                'userNo': '',
                'smSeq': '',
                'startDate': '',
                'endDate': ''
            }

            MyFactory.Date($scope, '#sendDetatDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                var end = $scope.searchData.endDate;
                var start = $scope.searchData.startDate;

                function getTime2Time($time1, $time2) {
                    var time1 = arguments[0],
                        time2 = arguments[1];
                    time1 = Date.parse(time1) / 1000;
                    time2 = Date.parse(time2) / 1000;
                    var time_ = time1 - time2;
                    return (time_ / (3600 * 24));
                }
                var days = getTime2Time(end, start);
                if (days > 31) {
                    App.alert('一次查询时间范围不能超过31天！');
                } else {
                    $scope.loaded = true;
                    MyFactory.PostAjax('/sendSm/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/sendSm/query', $scope.searchData, function (data) {
                            $scope.result = data.result;

                        })

                    });
                }

            }

            //下钻短信发送统计
            //短信发送统计下钻
            if (localStorage.getItem('sendStatToDs')) {
                var str = localStorage.getItem('sendStatToDs');
                var sendStatToDs = JSON.parse(str);
                MyFactory.getServiceCode($scope, 'listData2', sendStatToDs.svrNode);
                $scope.searchData = {
                    'limitCount': '500',
                    'startDate': sendStatToDs.tTime,
                    'endDate': sendStatToDs.tTime,
                    'sendSuc': sendStatToDs.sendSuc,
                    'sendFail': sendStatToDs.sendFail,
                    'recvSuc': sendStatToDs.recvSuc,
                    'recvFail': sendStatToDs.recvFail,
                    'recvNone': sendStatToDs.recvNone,
                    'svrNode': sendStatToDs.svrNode,
                    'serviceCode': sendStatToDs.serviceCode
                };

                $('#sendDetatDate').val(sendStatToDs.tTime + ' - ' + sendStatToDs.tTime);
                $scope.upData();

                localStorage.removeItem('sendStatToDs');
            } else {
                $scope.upData();
            }

            //显示条数和选择页数
            MyFactory.selectPage($scope)

            //业务端下拉列表
            MyFactory.setSms($scope);

            // 将日期字符串格式化日期
            $scope.formatDate = function(dataString) {
                var format = "yyyy/MM/dd HH:mm:ss";
                return $filter('date')(new Date(dataString), format);
            };

            //查看详情
            $scope.seeDetail = function (recId) {
                MyFactory.PostAjax('/sendSm/detail', {
                    'recId': recId
                }, function (data) {
                    // 查看详细
                    $scope.showAll = false;
                    $scope.detailData = data;
                    // 发送时间
                    $scope.detailData.recvReportTime = $scope.formatDate(data.recvReportTime);
                    $scope.detailData.recvTime = $scope.formatDate(data.recvTime);
                    $scope.detailData.sendTime = $scope.formatDate(data.sendTime);
                    $scope.detailData.sendFeedbackTime = $scope.formatDate(data.sendFeedbackTime);
                    $scope.detailData.reportFeedbackTime = $scope.formatDate(data.reportFeedbackTime);
                })
            }
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                };
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        $scope.searchData.sendSuc = '';
                        $scope.searchData.sendFail = '';
                        $scope.searchData.recvSuc = '';
                        $scope.searchData.recvFail = '';
                        $scope.searchData.recvNone = '';
                        var strData = $("#sendDetatDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        if($scope.searchData.userNo!=''){
                            if ((/\d{5,11}/.test($scope.searchData.userNo))) {
                                $scope.errors = ''
                                $scope.upData();
                            } else {
                                $scope.errors = '请输入5~11的数字';
                            }
                        }else{
                            $scope.errors = ''
                            $scope.upData();
                        }
                    }
                } else {
                    $scope.searchData.sendSuc = '';
                    $scope.searchData.sendFail = '';
                    $scope.searchData.recvSuc = '';
                    $scope.searchData.recvFail = '';
                    $scope.searchData.recvNone = '';
                    var strData = $("#sendDetatDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    if($scope.searchData.userNo!=''){
                        if ((/\d{5,11}/.test($scope.searchData.userNo))) {
                            $scope.errors = ''
                            $scope.upData();
                        } else {
                            $scope.errors = '请输入5~11的数字';
                        }
                    }else{
                        $scope.errors = ''
                        $scope.upData();
                    }
                    // $scope.upData();
                }


            }
            //时间调用
            $('#sendDetatDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#sendDetatDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
        } else {

            location.href = '#/forbid';
        }
    });
})
//========短信接收明细==========//
app.controller('recieveDetail', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'recieveDetail', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                userNo: '',
                srvNode: '',
                serviceCode: '',
                startDate: '',
                endDate: '',
            }
            //业务端下拉列表
            MyFactory.setSms($scope);

            MyFactory.Date($scope, '#recieveStatDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                var end = $scope.searchData.endDate;
                var start = $scope.searchData.startDate;

                function getTime2Time($time1, $time2) {
                    var time1 = arguments[0],
                        time2 = arguments[1];
                    time1 = Date.parse(time1) / 1000;
                    time2 = Date.parse(time2) / 1000;
                    var time_ = time1 - time2;
                    return (time_ / (3600 * 24));
                }
                var days = getTime2Time(end, start);
                if (days > 31) {
                    App.alert('一次查询时间范围不能超过31天！');
                } else {
                    $scope.loaded = true;
                    MyFactory.PostAjax('/recvSm/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        $scope.loaded = false;
                        //回调
                        if (callback) {
                            callback();
                        }
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/recvSm/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    });
                }
                $scope.loaded = true;
                MyFactory.PostAjax('/recvSm/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/recvSm/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }


            //短信发送统计下钻
            if (localStorage.getItem('sendStatToUp')) {
                var str = localStorage.getItem('sendStatToUp');
                var sendStatToUp = JSON.parse(str);
                $scope.searchData = {
                    'startDate': sendStatToUp.tTime,
                    'endDate': sendStatToUp.tTime,
                    'svrNode': sendStatToUp.svrNode,
                };
                $('#upSmsStatisticsDate').val(sendStatToUp.tTime + ' - ' + sendStatToUp.tTime);
                $scope.upData();

                localStorage.removeItem('sendStatToUp');
            } else {
                $scope.upData();
            }

            //显示条数和选择页数
            MyFactory.selectPage($scope)

            //查看详情
            $scope.seeDetail = function (recId) {

                MyFactory.PostAjax('/recvSm/detail', {
                    'recId': recId
                }, function (data) {
                    $scope.detailData = data;

                })
            }
            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        var strData = $("#recieveStatDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        if ($scope.searchData.svrNode == "") {
                            $scope.searchData.serviceCode = "";
                        }
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    var strData = $("#recieveStatDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    if ($scope.searchData.svrNode == "") {
                        $scope.searchData.serviceCode = "";
                    }
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }

            }
            //时间调用
            $('#recieveStatDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#recieveStatDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
        } else {

            location.href = '#/forbid';
        }
    });

})
//========短信文件导入==========//
app.controller('oprateRecord', function ($scope, $timeout, MyFactory, $http) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'oprateRecord', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {
                userNo: '',
                svrNode: '',
                serviceCode: '',
                startDate: '',
                endDate: '',
                fileType: '短信号码'
            }


            //业务端下拉列表
            MyFactory.setSms($scope);

            //时间的初始化
            MyFactory.Date($scope, '#sendFileDate', 'startDate', 'endDate');
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('uploadFile/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, 'uploadFile/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }
            $scope.upData();

            //显示条数和选择页数
            MyFactory.selectPage($scope)

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);
            };
            $scope.editData = {
                'svrNode': '',
                'serviceCode': '',
                'sendPort': '',
                'sendMode': '',
                'smContent': '',
                'file': '',
                'remark': '',
                'fileType': '短信号码'
            }
            $scope.editTr = function (code) {
                MyFactory.PostAjax('uploadFile/toUpdate', {
                    'fileId': code
                }, function (data) {
                    $scope.editData.serviceCode = data.serviceCode;
                    $scope.editData.svrNode = data.svrNode;
                    $scope.editData.sendPort = data.sendPort;
                    $scope.editData.sendMode = data.sendMode;
                    $scope.editData.smContent = data.smContent;
                    $scope.editData.remark = data.remark;
                })
            }

            //添加和修改数据
            $scope.editSave = function () {
                var input = document.querySelectorAll(".modal-body select")
                var isSave = true
                for (var i = 0; i < input.length; i++) {
                    if (input[i].value == '') {
                        isSave = false;
                    }
                }
                if (!isSave) {
                    App.prompt(input)
                    return
                }
                //信息无误开始请求
                MyFactory.PostAjax('uploadFile/update', $scope.editData, function (data) {
                    if (data.isSuccess == true) {
                        $scope.upData();
                        App.alert(data.msg, function () {
                            $('#edit').modal('hide');
                        })
                    } else {
                        App.alert(data.msg);
                    }
                })
            }
            //导入
            $scope.addData = {
                'svrNode': '',
                'serviceCode': '',
                'sendPort': '',
                'sendMode': '',
                'smContent': '',
                'file': '',
                'remark': '',
                'fileFormat': 'txt',
                'fileType': '短信号码'
            };




            //
            $scope.addServiceCode = function () {

            }

            //给隐藏的那部分表单值

            $scope.addServiceCode = function () {

                App.d('#serviceCode').value = $scope.addData.serviceCode;
            }
            $scope.addSendPort = function () {

                App.d('#sendPort').value = $scope.addData.sendPort;
            }

            $scope.selFileFormat = function () {
                App.d('#fileFormat').value = $scope.addData.fileFormat;
            };

            $scope.importFiole = function (value, id) {
                $scope.popup = value;
                if (value == '修改') {
                    App.d('#fileId1').value = id;
                    App.d('#fileId2').value = id;
                    $scope.isHide = {
                        'display': 'block'
                    };
                    $scope.isEdit = false;
                    //清空表单
                    $scope.addData = {
                        'svrNode': '',
                        'serviceCode': '',
                        'sendPort': '',
                        'sendMode': '',
                        'smContent': '',
                        'remark': '',
                        'fileFormat': '',
                        'fileType': '短信号码'
                    };
                    $("#file1").val("");
                    $("#file2").val("");
                    //请求修改的数据
                    MyFactory.PostAjax('uploadFile/toUpdate', {
                        'fileId': id
                    }, function (data) {
                        MyFactory.getServiceCode($scope, 'serviceList', data.svrNode);
                        $scope.addData = {
                            'svrNode': data.svrNode,
                            'serviceCode': data.serviceCode,
                            'sendPort': data.sendPort,
                            'sendMode': data.sendMode,
                            'smContent': data.smContent,
                            'fileId': id,
                            'remark': data.remark,
                        }
                        if (data.sendMode == '2') {
                            $(".phone").show();
                            $(".upFile").hide();
                            $(".isInit").prop("checked", "true");
                            $scope.addData.file1 = data.fileName;
                            $scope.prefix = "号码群发.";
                        } else {
                            $(".phone").hide();
                            $(".upFile").show();
                            $(".isOut").prop("checked", "true");
                            $scope.addData.file2 = data.fileName;
                            $scope.prefix = "短信文件.";
                        }
                    })

                } else {
                    $scope.isHide = {
                        'display': 'none'
                    };
                    $scope.addData = {
                        'svrNode': '',
                        'serviceCode': '',
                        'sendPort': '',
                        'sendMode': '',
                        'smContent': '',
                        'remark': '',
                        'fileFormat': '',
                        'fileType': '短信号码'
                    };
                    $("#file2").val('');
                    $("#file1").val('');
                    $(".phone").show();
                    $(".upFile").hide();
                    $(".isInit").prop("checked", "true");
                    $scope.prefix = "号码群发.";
                }


            }

            //修改的填充file
            $scope.hideLabel = function ($event) {
                var ele = $event.target;
                ele.style.display = 'none';
                $(ele).siblings('input').click();
            }
            $('#file1').change(function () {
                if ($scope.popup == "修改") {
                    if ($(this).val() == '') {
                        $scope.$apply($scope.isEdit = false);
                        $scope.$apply($scope.isHide = {
                            'display': 'block'
                        });
                    } else {
                        $scope.$apply($scope.isEdit = true);
                        $scope.$apply($scope.isHide = {
                            'display': 'none'
                        })
                    }
                }
            })
            $('#file2').change(function () {
                if ($scope.popup == "修改") {
                    if ($(this).val() == '') {
                        $scope.$apply($scope.isEdit = false);
                        $scope.$apply($scope.isHide = {
                            'display': 'block'
                        });
                    } else {
                        $scope.$apply($scope.isEdit = true);
                        $scope.$apply($scope.isHide = {
                            'display': 'none'
                        })
                    }
                }
            })



            //修改和添加下拉
            MyFactory.changeSvrNode($scope);


            //选中导入类型

            $(".isInit").change(function () {
                if ($(".isInit").prop("checked")) {
                    $(".phone").show();
                    $(".upFile").hide();
                    App.d('#sendMode').value = '2';
                    $scope.prefix = "号码群发.";
                    // $scope.addData.sendMode='2'
                } else {
                    $(".upFile").show();
                    $(".phone").hide();

                }
            })

            $(".isOut").change(function () {
                if ($(".isOut").prop("checked")) {
                    //          $(".isInit").prop("checked","false");
                    $(".upFile").show();
                    $(".phone").hide();
                    App.d('#sendMode').value = '3';
                    //$scope.addData.sendMode='3'
                    $scope.prefix = "短信文件.";
                } else {
                    $(".phone").show();
                    $(".upFile").hide();
                }
            })


            $scope.download = function () {
                if ($scope.addData.fileFormat == '') {
                    App.alert('请选择短信模板下载格式');
                    return
                }
                $scope.downParam = $scope.addData.fileFormat;
                // $scope.downParam = '' + $scope.prefix + $scope.addData.fileFormat;
                var aElement = document.createElement('a');
                aElement.href = 'uploadFile/download?fileName=' + $scope.prefix + $scope.addData.fileFormat;
                aElement.download = $scope.downParam;
                document.body.appendChild(aElement);
                aElement.click();
//                MyFactory.PostAjax('uploadFile/download', {
//                    'fileName': $scope.downParam
//                }, function (data) {
//                    if (data.isSuccess == false) {
//                    	var aElement = document.creat
//                    	App.alert(data.msg);
//                    } else {
//                    	$scope.upData();
//                    }
//                })
            }


            //导入文件

            $scope.statusLoad = {
                'display': 'none'
            };
            $scope.loadStatus = '导入';
            $scope.daoru = function () {
                if ($scope.addData.svrNode == '' || $scope.addData.serviceCode == '') {
                    App.alert('请选择业务端和短信类型');
                    return
                }
                var file1 = $("#file1").val();
                var file2 = $("#file2").val();
                var isInit = $(".isInit").prop("checked");
                var isOut = $(".isOut").prop("checked");


                //判断导入还是修改
                var url = '';
                if ($scope.popup == '导入') {
                    Aurl = 'uploadFile/upload';
                } else {
                    Aurl = 'uploadFile/update'
                }

                //群发
                if ((file1 == "") && (isInit == true) && $scope.popup != '修改') {
                    App.alert("上传文件不能为空")
                } else if (isInit == true) {

                    if ($scope.popup == '导入') {
                        if (file1.indexOf('.txt') == -1 && file1.indexOf('.csv') == -1
                            && file1.indexOf('.xls') == -1 && file1.indexOf('.xlsx') == -1) {
                            return App.alert("导入文件不是txt/csv/xls/xlsx,请重新导入文件");
                        }
                    }

                    $scope.statusLoad = {
                        'display': 'block'
                    };
                    $("#uploadForm").ajaxSubmit({
                        url: Aurl,
                        type: "POST",
                        contentType: "application/x-www-form-urlencoded; charset=utf-8",
                        success: function (data) {
                            $scope.$apply($scope.statusLoad = {
                                'display': 'none'
                            });

                            var data = JSON.parse(data);
                            data = data[0];
                            App.alert(decodeURIComponent(data.msg), function () {
                                if (data.success == true) {
                                    $("#import").modal('hide')
                                    $scope.upData();
                                }

                            });
                        },
                        error: function (data) {
                            $scope.$apply($scope.statusLoad = {
                                'display': 'none'
                            })
                            App.alert(decodeURIComponent(data.msg));

                        }
                    });
                }


                //上传短信文件
                if ((file2 == "") && (isOut == true) && $scope.popup != '修改') {
                    App.alert("上传文件不能为空")
                } else if (isOut == true) {
                    //修改判断上传文件为空
                    if ($scope.popup == '导入') {

                        if (file2.indexOf('.txt') == -1 && file2.indexOf('.csv') == -1
                            && file2.indexOf('.xls') == -1 && file2.indexOf('.xlsx') == -1) {
                            return App.alert("导入文件不是txt/csv/xls/xlsx,请重新导入文件");
                        }
                    }

                    //开始发送表单
                    $scope.statusLoad = {
                        'display': 'block'
                    };
                    $("#addUploadForm").ajaxSubmit({
                        url: Aurl,
                        type: "POST",
                        contentType: "application/x-www-form-urlencoded; charset=utf-8",
                        success: function (data) {
                            $scope.$apply($scope.statusLoad = {
                                'display': 'none'
                            })
                            var data = JSON.parse(data);
                            data = data[0];
                            App.alert(decodeURIComponent(data.msg), function () {
                                if (data.success == true) {
                                    $("#import").modal('hide');
                                    $scope.upData();
                                }

                            });
                        },
                        error: function (data) {
                            $scope.$apply($scope.statusLoad = {
                                'display': 'none'
                            })
                            App.alert('服务器忙，请稍候再试');
                        }
                    });


                }

            }


            //删除信息
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            }
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/uploadFile/delete', {
                    'fileIds': $scope.deleteId,
                    'fileType': '短信号码'
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.result.splice($scope.deleteIndex, 1);
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })
            };
            //审核
            $scope.changeStstus = function (index, id) {

                $scope.sendData = {
                    'auditStatus': '1',
                    'fileId': id,
                }
                $scope.sendAjax = function () {
                    MyFactory.PostAjax('/uploadFile/audit', {
                        'fileId': $scope.sendData.fileId,
                        'auditStatus': $scope.sendData.auditStatus
                    }, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#audit').modal('hide');
                            });
                        }
                        if (data.isSuccess == false) {
                            App.alert(data.msg)
                        }
                    })
                }
            }

            //查询
            $scope.search = function () {
                var strData = $("#sendFileDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);
                if ($scope.searchData.svrNode == "") {
                    $scope.searchData.serviceCode = "";
                }
                $scope.searchData.pageNo = 1;
                $scope.upData();
            }


            //显示信息详情
            $scope.showSmContent = function (content) {
                $scope.showSmsMessage = content;
            }


            //下钻短信导入明细
            $scope.GoDetail = function (tTime, status, fileId) {
                var obj = {
                    'tTime': tTime.substr(0, 10),
                    'status': status,
                    'fileId': fileId,
                }
                var str = JSON.stringify(obj);
                localStorage.setItem('oprateRecord', str);
                location.href = '#/opratedetails';
            }
        } else {

            location.href = '#/forbid';
        }
    });
})
//========单条短信发送==========//
app.controller('sendOprate', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'sendOprate', function (data) {
        if (data.data.isSuccess) {
            //业务端下拉列表
            MyFactory.setSms($scope)

            //搜索模型
            $scope.searchData = {
                svrNode: '',
                serviceCode: '',
                sendPort: '',
                phone: '',
                smContent: '',
                desc: ''
            }
            $scope.statusLoad = {
                'display': 'none'
            };
            $scope.loadStatus = '发送';
            $scope.senFn = function () {

                if (!App.regEx($scope.searchData.phone, 'phone')) {
                    App.alert('请输入正确的手机格式');
                    return;
                }
                if ($scope.searchData.svrNode == '') {
                    App.alert('请选择业务端类型');
                    return
                }
                if ($scope.searchData.serviceCode == '') {
                    App.alert('请选择短信类型');
                    return
                }
                if ($scope.searchData.smContent == '') {
                    App.alert("请输入发送内容")
                    return
                }

                $scope.statusLoad = {
                    'display': 'block'
                };
                MyFactory.PostAjax('/webSmRec/save', $scope.searchData, function (data) {

                    if (data.isSuccess == true) {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        App.alert(data.msg);
                        $scope.searchData = {
                            svrNode: '',
                            serviceCode: '',
                            sendPort: '',
                            phone: '',
                            smContent: '',
                            desc: ''
                        }
                    } else {
                        $scope.statusLoad = {
                            'display': 'none'
                        };
                        App.alert(data.msg);
                    }
                })
            }
            //取消重置表单
            $scope.clearContent = function () {
                $scope.searchData = {
                    svrNode: '',
                    serviceCode: '',
                    sendPort: '',
                    phone: '',
                    smContent: '',
                    desc: ''
                }
            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//=======短信导入明细==========//
app.controller('opratedetails', function ($scope, $timeout, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'opratedetails', function (data) {
        if (data.data.isSuccess) {
            //时间调用
            $scope.searchData = {
                fileName: '',
                status: '',
                startDate: '',
                endDate: '',
                fileType: '短信号码'
            }
            MyFactory.Date($scope, '#oprateDate', 'startDate', 'endDate');

            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/inputLine/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //回调
                    if (callback) {
                        callback();
                    }
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/inputLine/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })

                });
            }

            if (localStorage.getItem('oprateRecord')) {
                var str = localStorage.getItem('oprateRecord');
                var oprateRecord = JSON.parse(str);
                $scope.searchData = {
                    'status': oprateRecord.status,
                    'startDate': oprateRecord.tTime,
                    'endDate': oprateRecord.tTime,
                    'fileId': oprateRecord.fileId,
                    'fileType': '短信号码'
                };

                $('#oprateDate').val(oprateRecord.tTime + '-' + oprateRecord.tTime);
                $scope.upData();
                localStorage.removeItem('oprateRecord');
            } else {
                $scope.upData();
            }

            //显示条数和选择页数
            MyFactory.selectPage($scope)

            //导出表格信息
            $scope.loadStyle = {
                'display': 'none'
            }
            $scope.outExcel = function () {
                $scope.loadStyle = {
                    'display': 'block'
                }
                $('#form').submit();
                $timeout(function () {
                    $scope.loadStyle = {
                        'display': 'none'
                    }
                }, 500);

            };
            //查询
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        var strData = $("#oprateDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.searchData.fileId = '';
                        $scope.upData();
                    }
                } else {
                    var strData = $("#oprateDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.searchData.fileId = '';
                    $scope.upData();
                }

            }

            $('#oprateDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#oprateDate").val();
                $scope.$apply($scope.searchData.startDate = strData.substring(0, 10));
                $scope.$apply($scope.searchData.endDate = strData.substring(12));

            });
        } else {

            location.href = '#/forbid';
        }
    });

})

//========用户管理==========//
app.controller('userManagement', function ($scope, MyFactory) {

    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'userManagement', function (data) {
        if (data.data.isSuccess) {
            //搜索数据模型
            $scope.searchData = {
                'userName': '',
                'phoneNumber': '',
                'deptId': '',
                'pageSize': '5'
            }
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/users/query', $scope.searchData,
                    function (data) {

                        $scope.result = data.result;
                        //数据的初始化
                        for (var i = 0; i < $scope.result.length; i++) {
                            if (data.result[i].roleNames == "") {
                                $scope.result[i].roleNames = "添加角色";
                            } else {
                                $scope.result[i].roleNames = data.result[i].roleNames;
                            }
                            if (data.result[i].status == "") {
                                $scope.result[i].status = "1";
                            } else {
                                $scope.result[i].status = data.result[i].status;
                            }
                        }
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        if (callback) {
                            callback();
                        }
                        $scope.loaded = false;
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/users/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                            //数据的初始化
                            for (var i = 0; i < $scope.result.length; i++) {
                                if (data.result[i].roleNames == "") {
                                    $scope.result[i].roleNames = "添加角色";
                                } else {
                                    $scope.result[i].roleNames = data.result[i].roleNames;
                                }
                                if (data.result[i].status == "") {
                                    $scope.result[i].status = "1";
                                } else {
                                    $scope.result[i].status = data.result[i].status;
                                }
                            }

                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            MyFactory.PostAjax('/menu/getAll', {}, function (data) {
                var zNodes = [];
                for (var i = 0; i < data.length; i++) {
                    zNodes.push({
                        'id': data[i].menuId,
                        'pId': data[i].parentId,
                        'name': data[i].menuName
                    })
                }

                //初始化树插件
                var setting = {
                    check: {
                        enable: true
                    },
                    data: {
                        simpleData: {
                            enable: true
                        }
                    }
                };

                $.fn.zTree.init($("#treeDemo"), setting, zNodes);
            })


            //归属单位
            MyFactory.PostAjax('/dept/getAll', {}, function (data) {
                $scope.listData1 = data;

            })




            $scope.pddData = {
                'deptName': ''
            }
            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        $scope.searchData.deptId = $scope.pddData.deptName;
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    $scope.searchData.deptId = $scope.pddData.deptName;
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }

            }

            //角色列表
            MyFactory.PostAjax('/role/getAll', {}, function (data) {
                $scope.result2 = data;

            })


            $scope.roleData = function (id) {
                $scope.useId = id;
                for (var x = 0; x < $(".checked").length; x++) {
                    $(".checked").eq(x).prop("checked", "")
                }
                MyFactory.PostAjax('/users/getUserRoles', {
                    'userId': $scope.useId
                }, function (data) {
                    $scope.listData2 = data;

                    for (var i = 0; i < $scope.result2.length; i++) {
                        for (var j = 0; j < data.length; j++) {
                            if (data[j].roleId == $scope.result2[i].roleId) {
                                $(".checked").eq(i).prop("checked", "checked")
                            }
                        }
                    }
                })

            }




            $scope.quanData = function (roleId) {
                $scope.roleId = roleId
                MyFactory.PostAjax('menu/getMenusByRole', {
                    'roleId': $scope.roleId
                }, function (data) {

                    var zNodes = [];
                    for (var i = 0; i < data.length; i++) {
                        zNodes.push({
                            'id': data[i].menuId,
                            'pId': data[i].parentId,
                            'name': data[i].menuName,
                            'checked': true
                        })
                    }
                    $scope.zNodes = zNodes;
                    var setting = {
                        check: {
                            enable: true,
                            checkType: 'checkbox'
                        },
                        data: {
                            simpleData: {
                                enable: true
                            }
                        }
                    };

                    $.fn.zTree.init($("#treeDemo"), setting, $scope.zNodes);

                })
            }


            $scope.saveData = function () {
                $scope.addroleId = [];
                $scope.add = '';
                for (var i = 0; i < $scope.result2.length; i++) {
                    var check = $(".checked").eq(i).prop("checked");
                    var roleId = $scope.result2[i].roleId;
                    if (check == true) {
                        $scope.addroleId.push(roleId);
                    }
                }
                MyFactory.PostAjax('/users/changeUserRoles', {
                    'userId': $scope.useId,
                    'roleIds': $scope.addroleId
                }, function (data) {
                    $scope.listData2 = data;
                    if (data.isSuccess == true) {
                        App.alert(data.msg, function () {
                            $('.bs-example-moda3').modal('hide');
                        })
                    } else {
                        App.alert(data.msg)
                    }
                    $scope.upData();
                })

            }

            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('/users/changeStatus', {
                    'userId': code,
                    'status': status
                }, function (data) {


                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }

            //====添加tr和编辑tr====//
            $scope.addData = {
                'userId': '',
                'userName': '',
                'sex': '2',
                'phoneNumber': '',
                'pwd': '',
                'mailBox': '',
                'deptId': '',
                'remark': ''
            }

            $scope.editTr = function (value, id) {
                $scope.popup = value;
                if ($scope.popup == '添加') {
                    $scope.addData = {
                        'userId': '',
                        'userName': '',
                        'sex': '2',
                        'phoneNumber': '',
                        'pwd': 'CSmm123456',
                        'mailBox': '',
                        'deptId': '',
                        'remark': ''
                    }
                    $scope.addData.deptId = $scope.listData1[0].deptId;
                } else {
                    $scope.editId = id;
                    //密码初始化
                    MyFactory.PostAjax('/users/toUpdate', {
                        'userId': $scope.editId
                    }, function (data) {

                        $scope.addData = {
                            'userId': '',
                            'userName': '',
                            'sex': '2',
                            'phoneNumber': '',
                            'pwd': '',
                            'mailBox': '',
                            'deptId': '',
                            'remark': ''
                        };
                        $scope.addData.userId = data.userId;
                        $scope.addData.userName = data.userName;
                        $scope.addData.sex = data.sex;
                        $scope.addData.phoneNumber = parseInt(data.phoneNumber);
                        $scope.addData.pwd = data.pwd;
                        $scope.oldPwd = data.pwd;
                        $scope.addData.mailBox = data.mailBox;
                        $scope.addData.deptId = data.deptId;
                        $scope.addData.remark = data.remark;
                    })
                }
            };


            //初始化密码
            $scope.adtpow = function () {
                $scope.addData.pwd = "CSmm123456";
            };

            // 检验密码规则是否正确
            $scope.checkPassword = function (password) {
                // 8到16位，且包含大写字母、小写字母、数字和特殊符号任意三种以上组合
                var regex = /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_]+$)(?![a-z0-9]+$)(?![a-z\W_]+$)(?![0-9\W_]+$)[a-zA-Z0-9\W_]{8,16}$/;
                return regex.test(password);
            };

            //保存
            $scope.editSave = function () {
                if ($scope.popup == '修改') {
                    var input = $('.bs-example-modal input');

                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return
                    }
                    var email = $(".email").val();
                    // var rem=/^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi
                    if (email != "") {
                        if (!email.match(/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/)) {
                            App.alert("非法邮箱！请重新输入");
                            return
                        }
                    }
                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($("#phones").val())) {
                        App.alert('请输入有效的手机号码！');
                        return false;
                    }

                    // 验证密码复杂度，编辑时，若未修改密码，则直接跳过
                    if($scope.oldPwd != $scope.addData.pwd && !$scope.checkPassword($scope.addData.pwd)) {
                        return App.alert("请设置8到16位，且包含大写字母、小写字母、数字和特殊符号任意三种以上组合的有效密码!");
                    }
                    $scope.addData.pwd = hex_md5($scope.addData.pwd);
                    // 发起修改用户信息请求
                    MyFactory.PostAjax('/users/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('.bs-example-modal').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })

                } else if ($scope.popup == '添加') {

                    var input = $('.bs-example-modal input');

                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return
                    }
                    var email = $(".email").val();
                    if (email != "") {
                        if (!email.match(/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/)) {
                            alert(email);
                            App.alert("非法邮箱！请重新输入");
                            return
                        }
                    }

                    //手机号码的验证
                    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
                    if (!myreg.test($("#phones").val())) {
                        App.alert('请输入有效的手机号码！');
                        return false;
                    }

                    // 验证密码复杂度
                    if(!$scope.checkPassword($scope.addData.pwd)) {
                        return App.alert("请设置8到16位，且包含大写字母、小写字母、数字和特殊符号任意三种组合的有效密码!");
                    }
                    $scope.addData.pwd = hex_md5($scope.addData.pwd);

                    // 发起新增用户接口请求
                    MyFactory.PostAjax('/users/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('.bs-example-modal').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                    })
                }

            }

            $scope.linkTo = function () {
                $('.bs-example-moda3').modal('hide');
                $('.menu-second a').removeClass('menu-second-active');
                $('.role').addClass('menu-second-active');
                //$timeout(function(){
                location.href = '#/roleManagement';
                //},10);

            }

            ///====删除tr====//
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/users/delete', {
                    'userId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })

            };
            //退出在线状态
            $scope.exitUser = function (userId) {
                MyFactory.PostAjax('users/logout', {
                    'userId': userId
                }, function (data) {
                    if (data.isSuccess == true) {
                        App.alert('退出成功');
                        $scope.upData();
                    } else {
                        App.alert('退出失败');
                    }
                })
            }
        } else {

            location.href = '#/forbid';
        }
    });

})
//========角色管理==========//
app.controller('roleManagement', function ($scope, MyFactory) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'roleManagement', function (data) {
        if (data.data.isSuccess) {
            //搜索数据模型
            $scope.searchData = {
                'roleName': '',

            }
            //初始化数据
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/role/query', $scope.searchData,
                    function (data) {

                        $scope.result = data.result;
                        //数据的初始化
                        for (var i = 0; i < $scope.result.length; i++) {
                            if (data.result[i].roleNames == "") {
                                $scope.result[i].roleNames = "运维人员";
                            } else {
                                $scope.result[i].roleNames = data.result[i].roleNames;
                            }
                            if (data.result[i].status == "") {
                                $scope.result[i].status = "1";
                            } else {
                                $scope.result[i].status = data.result[i].status;
                            }
                        }
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        if (callback) {
                            callback();
                        }
                        $scope.loaded = false;
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/role/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })

                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            MyFactory.PostAjax('/menu/getAll', {}, function (data) {
                var zNodes = [];
                for (var i = 0; i < data.length; i++) {
                    zNodes.push({
                        'id': data[i].menuId,
                        'pId': data[i].parentId,
                        'name': data[i].menuName
                    })
                }

                $scope.zNodes = zNodes;
            })


            //权限设置
            $scope.queData = function (id, acsFlag) {

                $scope.queId = id;
                $scope.flag = acsFlag;
                MyFactory.PostAjax('/role/getRoleMenus', {
                    "roleId": $scope.queId
                }, function (data) {
                    for (var i = 0; i < $scope.zNodes.length; i++) {
                        $scope.zNodes[i].checked = false;
                    }
                    for (var i = 0; i < $scope.zNodes.length; i++) {
                        for (var j = 0; j < data.length; j++) {
                            if (data[j].menuId == $scope.zNodes[i].id) {
                                $scope.zNodes[i].checked = true;
                            }
                        }
                    }

                    var setting = {
                        check: {
                            enable: true,
                            checkType: 'checkbox'
                        },
                        data: {
                            simpleData: {
                                enable: true
                            }
                        }
                    };

                    $.fn.zTree.init($("#treeDemo"), setting, $scope.zNodes);

                })
            }


            $scope.auesave = function () {
                var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
                var nodes = treeObj.getCheckedNodes(true);

                var id = [];
                for (var i = 0; i < nodes.length; i++) {
                    id.push(nodes[i].id)
                }
                var ids = id.join(",")
                MyFactory.PostAjax('/role/changeMenusAndAcsFlag', {
                    "roleId": $scope.queId,
                    "menuIds": ids,
                    "acsFlag": $scope.flag
                }, function (data) {
                    $scope.listData3 = data;
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData();
                        App.alert(data.msg, function () {
                            $('#myModal').modal('hide');
                        })
                    }
                })

            }


            //生效 失效
            $scope.changeStstus = function (index, code, status) {
                status === '0' ? status = '1' : status = '0';
                MyFactory.PostAjax('/role/changeStatus', {
                    'roleId': code,
                    'status': status
                }, function (data) {


                    if (data.isSuccess == true) {
                        $scope.result[index].status = status;
                        if (status === '0') {
                            $scope.result[index].statusStr = '失效'
                        } else {
                            $scope.result[index].statusStr = '有效'
                        }
                        App.alert(data.msg)
                    } else {
                        App.alert(data.msg)
                    }
                })
            }
            //====添加tr和编辑tr====//
            $scope.addData = {
                'roleId': '',
                'roleName': '',
                'status': '1',
                'acsFlag': '1',
                'remark': ''

            }
            $scope.editTr = function (value, id) {
                $scope.popup = value;
                if ($scope.popup == '添加') {
                    $scope.addData = {
                        'roleId': '',
                        'roleName': '',
                        'status': '1',
                        'acsFlag': '1',
                        'remark': ''
                    }
                } else {
                    $scope.editId = id;
                    MyFactory.PostAjax('/role/toUpdate', {
                        'roleId': $scope.editId
                    }, function (data) {
                        $scope.addData = {
                            'roleId': '',
                            'roleName': '',
                            'status': '',
                            'acsFlag': '',
                            'remark': ''
                        };
                        $scope.addData.roleId = data.roleId;
                        $scope.addData.roleName = data.roleName;
                        $scope.addData.status = data.status;
                        $scope.addData.acsFlag = data.acsFlag;
                        $scope.addData.remark = data.remark;
                    })
                }
            };
            $scope.editSave = function () {
                if ($scope.popup == '修改') {
                    var input = $('.modal-body [ type="text"]');
                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return
                    }
                    MyFactory.PostAjax('/role/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#cop').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                        $scope.upData();
                    })

                } else if ($scope.popup == '添加') {
                    var input = $('.modal-body [ type="text"]');
                    var bool = true;
                    for (var i = 0; i < input.length; i++) {
                        if (input[i].value == '') {
                            bool = false && bool;
                        }
                    }
                    if (!bool) {
                        App.prompt(input);
                        return
                    } else if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return
                    }
                    MyFactory.PostAjax('/role/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('#cop').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }

                    })
                    $scope.upData();
                }

            }
            ///====删除tr====//
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/role/delete', {
                    'roleId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })

            };
        } else {

            location.href = '#/forbid';
        }
    });
})


//========组织管理==========//
app.controller('organizationManagement', function ($scope, $http, MyFactory, $rootScope, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'organizationManagement', function (data) {
        if (data.data.isSuccess) {
            $scope.searchData = {};
            //初始化数据
            $scope.upData = function (callback) {
                $scope.loaded = true;
                MyFactory.PostAjax('/dept/query', $scope.searchData,
                    function (data) {
                        $scope.result = data.result;
                        $scope.selPage = data.pageNo;
                        $scope.count = data.totalCount;
                        $scope.totalCount = data.totalPages;
                        if (callback) {
                            callback();
                        }
                        $scope.loaded = false;
                        //分页
                        MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/dept/query', $scope.searchData, function (data) {
                            $scope.result = data.result;
                        })


                    }
                );
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);

            //单位等级下拉列表
            MyFactory.PostAjax('/dicDef/getByDicName', {
                "dicName": 'deptLevel'
            }, function (data) {
                $scope.listData1 = data;
            })
            //业务端下拉列表
            MyFactory.PostAjax('/svrNodeDef/getSvrNode', {}, function (data) {
                $scope.listData = data;
            })

            //设置业务端
            $scope.revise = function (id) {
                $scope.sedId = id;
                for (var i = 0; i < $(".svr").length; i++) {
                    $(".svr").eq(i).prop("checked", "");
                }
                MyFactory.PostAjax('/dept/getDeptSvrNodes', {
                    "deptId": $scope.sedId
                }, function (data) {
                    $scope.listData3 = data;
                    for (var j = 0; j < $scope.listData3.length; j++) {
                        for (var i = 0; i < $(".svr").length; i++) {
                            if ($(".svr").eq(i).val() == $scope.listData3[j].svrNode) {
                                $(".svr").eq(i).prop("checked", "checked");

                            }
                        }
                    }


                })
            }

            $scope.keep = function () {
                $scope.svr = [];
                for (var i = 0; i < $(".svr").length; i++) {
                    if ($(".svr").eq(i).prop("checked") == true) {
                        var val = $(".svr").eq(i).val();
                        $scope.svr.push(val)
                    }
                }
                $scope.svrNode = $scope.svr.join(",")

                MyFactory.PostAjax('/dept/changeDeptSvrNodes', {
                    "deptId": $scope.sedId,
                    "svrNodes": $scope.svrNode
                }, function (data) {
                    $scope.listData4 = data;

                    if (data.isSuccess == true) {
                        $scope.upData();
                        App.alert(data.msg, function () {
                            $('#she').modal('hide');
                        })
                    } else {
                        App.alert(data.msg)
                    }

                })
            }

            //====添加tr和编辑tr====//
            $scope.addData = {
                //'deptId':'',
                'deptName': '',
                'deptLevel': '',
                'parentId': '',
                'remark': ''
            }
            $scope.editTr = function (value, id) {
                $scope.popup = value;
                if ($scope.popup == '单位创建') {
                    $scope.addData = {
                        //'deptId':'',
                        'deptName': '',
                        'deptLevel': '',
                        'parentId': '',
                        'remark': ''
                    }
                    $scope.addData.deptLevel = $scope.listData1[0].DICVALUE;
                    //上级单位等级下拉列表
                    $scope.$watch("addData.deptLevel", function (newValue, oldValue) {
                        angular.forEach($scope.listData1, function (key) {
                            if (key.DICVALUE == $scope.addData.deptLevel) {
                                $scope.dep = $scope.addData.deptLevel;
                            }
                        });
                        MyFactory.PostAjax('/dept/getUpLevelDept', {
                            "deptLevel": $scope.dep
                        }, function (data) {
                            $scope.listData2 = data;
                            $scope.dep = $scope.addData.deptLevel;
                        })

                    }, true)

                } else {
                    $scope.editId = id;
                    MyFactory.PostAjax('/dept/toUpdate', {
                        'deptId': $scope.editId
                    }, function (data) {
                        $scope.addData = {
                            'deptId': '',
                            'deptName': '',
                            'deptLevel': '',
                            'parentId': '',
                            'remark': ''
                        };
                        $scope.addData.deptId = data.deptId;
                        $scope.addData.deptName = data.deptName;
                        $scope.addData.deptLevel = data.deptLevel;
                        $scope.$watch("addData.deptLevel", function (newValue, oldValue) {
                            angular.forEach($scope.listData1, function (key) {

                                if (key.DICVALUE == $scope.addData.deptLevel) {
                                    $scope.dep = $scope.addData.deptLevel;
                                }
                            });
                            MyFactory.PostAjax('/dept/getUpLevelDept', {
                                "deptLevel": $scope.dep
                            }, function (data) {
                                $scope.listData2 = data;

                                $scope.dep = $scope.addData.deptLevel;

                                // $scope.addData.parentId= $scope.listData2[0].deptId;
                            })
                        }, true)
                        $scope.addData.parentId = data.parentId;
                        $scope.addData.remark = data.remark;

                    })
                }
            };
            $scope.editSave = function () {
                if ($scope.popup == '单位修改') {
                    var val1 = $(".unitname").val();
                    if (val1 == "") {
                        $(".unitname").focus
                        App.alert("单位名称不能为空");
                        return
                    }
                    if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return
                    }
                    MyFactory.PostAjax('/dept/update', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('.bs-example-moda').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }
                        $scope.upData();
                    })

                } else if ($scope.popup == '单位创建') {

                    var val1 = $(".unitname").val();
                    if (val1 == "") {
                        App.alert("单位名称不能为空");
                        $(".unitname").focus()
                        return
                    }


                    if (App.d('.modal-body textarea').value == '') {
                        App.promptOne(App.d('.modal-body textarea'));
                        return
                    }
                    MyFactory.PostAjax('/dept/save', $scope.addData, function (data) {
                        if (data.isSuccess == true) {
                            $scope.upData();
                            App.alert(data.msg, function () {
                                $('.bs-example-moda').modal('hide');
                            })
                        } else {
                            App.alert(data.msg)
                        }


                    })
                    $scope.upData();
                }

            }

            ///====删除tr====//
            $scope.delete = function (id, index) {
                $scope.deleteId = id;
                $scope.deleteIndex = index;
            };
            $scope.deleteTr = function () {
                MyFactory.PostAjax('/dept/delete', {
                    'deptId': $scope.deleteId
                }, function (data) {
                    if (data.isSuccess == false) {
                        App.alert(data.msg)
                    } else if (data.isSuccess == true) {
                        $scope.upData(function () {
                            if ($scope.result.length < 1) {
                                if ($scope.searchData.pageNo > 1) {
                                    $scope.searchData.pageNo = $scope.searchData.pageNo - 1;
                                    $scope.upData();
                                }
                            }
                        });
                        App.alert(data.msg)
                    }
                })

            };
            $scope.pddData = {
                'deptName': ''
            }
        } else {

            location.href = '#/forbid';
        }
    });

})

//========日志管理==========//
app.controller('logManagement', function ($scope, $http, MyFactory, $rootScope, $timeout) {
    // 访问权限
    MyFactory.GetAjaxs('users/authentication', 'logManagement', function (data) {
        if (data.data.isSuccess) {
            //搜索数据模型
            $scope.searchData = {
                'logType': '',
                'userName': '',
                'startTime': '',
                'endTime': '',
            }
            //初始化数据
            $scope.upData = function () {
                $scope.loaded = true;
                MyFactory.PostAjax('/smLog/query', $scope.searchData, function (data) {
                    $scope.result = data.result;
                    for (var i = 0; i < $scope.result.length; i++) {
                        if (data.result[i].status == "") {
                            $scope.result[i].status = "1";
                        } else {
                            $scope.result[i].status = data.result[i].status;
                        }
                    }
                    $scope.selPage = data.pageNo;
                    $scope.count = data.totalCount;
                    $scope.totalCount = data.totalPages;
                    $scope.loaded = false;
                    //分页
                    MyFactory.PageArr($scope, $scope.selPage, $scope.totalCount, '/smLog/query', $scope.searchData, function (data) {
                        $scope.result = data.result;
                    })


                });
            }
            $scope.upData();

            //选择显示条数和页数跳转
            MyFactory.selectPage($scope);


            $scope.search = function (e) {
                if (e) {
                    var keycode = window.event ? e.keyCode : e.which;
                    if (keycode == 13) {
                        var strData = $("#sendStatDate").val();
                        $scope.searchData.startDate = strData.substring(0, 10);
                        $scope.searchData.endDate = strData.substring(12);
                        $scope.searchData.pageNo = 1;
                        $scope.upData();
                    }
                } else {
                    var strData = $("#sendStatDate").val();
                    $scope.searchData.startDate = strData.substring(0, 10);
                    $scope.searchData.endDate = strData.substring(12);
                    $scope.searchData.pageNo = 1;
                    $scope.upData();
                }

            }
            MyFactory.PostAjax('/dept/getAll', {}, function (data) {
                $scope.listData1 = data;

            })
            //时间调用
            MyFactory.Date($scope, '#sendStatDate', 'startDate', 'endDate');
            $('#sendStatDate').daterangepicker(null, function (start, end, label) {
                var strData = $("#sendStatDate").val();
                $scope.searchData.startDate = strData.substring(0, 10);
                $scope.searchData.endDate = strData.substring(12);

            });
        } else {

            location.href = '#/forbid';
        }
    });
})
app.controller('forbid', function ($scope, $http, MyFactory) {
    MyFactory.PostAjax('users/query', '', function (data) {
        if (data == null) {
            location.href = '#/login';
        }
    })

})
